Reputation: 67
I am trying to have a hyperlink binded with the product name and navigate to product details page according to id. The navigate url is always with product id 0. Here is my code
<asp:TemplateField HeaderText="Product Name">
<ItemTemplate>
<asp:HyperLink
ID="hl1"
Text='<%# Bind("Product_name") %>'
runat="server"
DataNavigateUrlFields="ProductId"
ControlStyle-ForeColor="#0066FF"
DataNavigateUrlFormatString="~/ProductDetails.aspx?ProductId{0}"
NavigateUrl="~/ProductDetails.aspx?ProductId{0}" />
</ItemTemplate>
</asp:TemplateField>
Upvotes: 1
Views: 4817
Reputation: 546
Use like this--
NavigateUrl='<%# Eval("ProductId","~/ProductDetails.aspx?ProductId{0}" ) %>'
Upvotes: 5