1

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>

1 Answer 1

5

Use like this--

NavigateUrl='<%# Eval("ProductId","~/ProductDetails.aspx?ProductId{0}" ) %>'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.