My scenario is: I have DataList with some products. My SqlDataSource takes all values but I display only picture, name and price. ProductID label visible in item template is set to false.
I have added an image button to each product and I would like to click this button and go to more specific details page of each product. My solution is to pass ProductID to details page. But, I am missing something and can't figure out how to do that.
My button:
<asp:ImageButton ID="ImageButton1" runat="server" CommandArgument='<%# Eval("productID")%>'
ImageUrl="~/Graphics/profile_button.png" onclick="ImageButton1_Click" />
Then onclick:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string productID = ???????
string url;
url = "~/ProductDetails.aspx?productid=" + ProductID;
Response.Redirect(url);
}
As you can see I dont know how to get CommandArgument. How to do that?