我在datalist中有来自数据库的图像。我想能够点击一张图片,这张图片可以带我到一个新的页面,在那里将显示图像,并且还会显示有关图像的信息。
<asp:HyperLink ID="hlnk" NavigateUrl='<%# string.Format("ViewProductDetail.aspx?Image={0}", Eval("Picture")) %>' runat="server">
<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 :(得分:1)
试试这个 根据此
在查询字符串中添加ProdcutId<asp:HyperLink ID="hlnk" NavigateUrl='<%# string.Format("ViewProductDetail.aspx?ProductId={0}", Eval("productid")) %>' runat="server">
<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
}