Click image in datalist

1.5k Views Asked by At

I have images in datalist which i get from database. I want to be able to click on an image which would than take me to a new page where the image would be displayed and the information about image would be displayed too.

<asp:HyperLink ID="hlnk" NavigateUrl='<%# string.Format("ViewProductDetail.aspx?Image={0}", Eval("Picture")) %>' runat="server">

        &nbsp;<asp:Image ID="Image1" runat="server" Height="127px" 
                ImageUrl='<%# Bind("Picture", "~/Image/{0}") %>' Width="129px" />

                </asp:HyperLink>

                <br />
        <asp:Label ID="ProductNameLabel" runat="server" 
            Text='<%# Eval("ProductName") %>' />
        <br />
        <asp:Label ID="PriceLabel" runat="server" 
            Text='<%# Eval("Price","{0:C}") %>' />

so what do i have to code for ViewProductDetail.aspx to retrieve the information of the images i click?

1

There are 1 best solutions below

0
On

Try This Add ProdcutId in query string according this

<asp:HyperLink ID="hlnk" NavigateUrl='<%# string.Format("ViewProductDetail.aspx?ProductId={0}", Eval("productid")) %>' runat="server">

    &nbsp;<asp:Image ID="Image1" runat="server" Height="127px" 
            ImageUrl='<%# Bind("Picture", "~/Image/{0}") %>' Width="129px" />

   </asp:HyperLink>

in ViewProductDetail.aspx page load event get ProductId Value from Query string

if(Request.Querystring["ProductId"] !=null && Request.Querystring["ProductId"] !="")
{
  //get product details from product id and show on page
}