1

I have looked everywhere for a tutorial on this how do I go about making a aspx page that I pass an ID for a item into so the url would be item.aspx?id=1042 and it would display data from sql database for item #1042. Does anyone have any information on how I do this, any articles or tutorials would be wonderful.

3 Answers 3

5

You don't really need a tutorial. Just use the Request.Querystring property like this:

int id = int.Parse(Request.Querystring("id").ToString());

// then use the id int in a db query

Good luck!

Sign up to request clarification or add additional context in comments.

1 Comment

I believe it should be int id = int.Parse(Request.QueryString["id"].ToString());
0

You should be looking at ASP.NET AJAX. Basically you send an XMLHttpRequest (AJAX) back to the server with the id parameter, parse it like Paul Sasik said, then query the db and render the response.

Comments

0
if (Request.QueryString.HasKeys())
{
    var values = Request.QueryString.GetValues("id");
    if (values != null)
    {
        var id= Convert.ToInt32(values[0]);
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.