2013-12-11 77 views
0

我有圖像datalist,我從數據庫中獲得。我希望能夠點擊一個圖像,而不是帶我到一個新的頁面,圖像將被顯示,圖像的信息也會顯示出來。點擊圖片在datalist

<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}") %>' /> 

那麼我有什麼編碼ViewProductDetail.aspx來檢索我點擊圖像的信息?

+0

你在ViewProductDetail.aspx有哪些代碼添加ProdcutId頁?你有什麼嘗試?另外,我認爲ASP.NET會比'image'更有用,至少添加ASP.NET標記。 –

+0

目前它的空>< 尋找一些指導我應該做什麼.. – shiny

回答

1

試一試 查詢字符串根據本

<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> 
在ViewProductDetail.aspx頁面加載事件

得到查詢字符串的ProductID值

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