asp binding returning wrong value from database

211 Views Asked by At

When I bind a url using the productID field from my access database it returns the wrong value for example as my database starts with the first field as 2 it returns -1, then -2 for 3 and so on.

<a href='details.aspx?ID=<%#Eval("ProductID") %>'>

thanks

2

There are 2 best solutions below

0
On

Try <a href="details.aspx?ID='<%#Eval("ProductID") %>'">

or

use asp hyperlink

<asp:HyperLink runat="server"
 NavigateUrl='details.aspx?ID=<%# Eval("ProductID") %>'
/>
0
On

try:

<a href="details.aspx?ID='<%# DataBinder.Eval(Container.DataItem, "ProductId")%>'">