Click here to Skip to main content
15,888,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to bind an id to an URL. I want the gridview I have on my aspx page to filter using the ID I gave in my database. I want this filter to be accessed through my URL ("product.aspx?Id=1");

How do I do this?
Posted
Comments
Rockstar_ 5-Jun-13 7:16am    
What u want dear?

 
Share this answer
 
The thing you are trying to achieve can be accomplished through the concept called Query Strings. Refer to below links to get better idea what query strings are and how to work with the same.

ASP QueryString Collection[^]

Passing variables between pages using QueryString[^]

Query String in Asp.net with Example in C#, VB.NET[^]

asp.net QueryString example: how to use QueryString[^]


You will pass data something like

VB
Response.Redirect("Webform2.aspx?Name=" +this.txtName.Text + "&LastName=" +this.txtLastName.Text);


and retrieve data like

C#
txtBox1.Text = Request.QueryString["Name"];
txtBox2.Text = Request.QueryString["LastName"];
 
Share this answer
 
1. just bind the gridview to the sqldatasource where you can customize the type of input parameter for the query.

ex: you can pass the querystring or (ID) as the selectparameter in SqlDatasource.

2. if you are binding it through code i.e., Either Dataset or Datatable you can query it on the Page_load it reflects in the gridview.

DataTable.Select() method...

for reference view this [^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900