I am using a datalist on customer page to list all customers. There is a page named “view” where I want to show the details of the particular selected customer. Here is the image button code:
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# GetImageURL(Eval("image")) %>' PostBackUrl='<%# Eval("id", "view.aspx?id={0}") %>'/></tr>
id is the unique field of the customer table. Now how should I retrieve the customer data on view.aspx, using the particular ID passed from the customer page. I use this code but it’s not working:
Dim mycommand As New SqlCommand("SELECT * FROM customer where id = @id", con)
Int(ID = Request.QueryString("id"))
con.Open()
ProfileData.DataSource = mycommand.ExecuteReader
ProfileData.DataBind()
con.Close()
I just want to do that. In the customer page all customers are displayed with their image and when I click on any one of them then the details of the particular customer should be displayed on view.aspx page ..
you are using @id as CommandParameter to add this
idas value to command parameter..as
check these link to know about the parameter..
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx
http://msdn.microsoft.com/en-us/library/yy6y35y8%28v=vs.80%29.aspx