Try:
Following binds the ItemID to the CommandArgument of the LinkButton.
<asp:LinkButton ID="LinkButton1" runat="server" Text="Add to cart"
OnClick="LinkButton1_Click" CommandArgument='<%# Eval("ItemID") %>' />
You can then retrieve it like this in the code behind:
protected void LinkButton1_Click(object sender, EventArgs e)
{
LinkButton myButton = sender as LinkButton;
if (myButton != null)
{
int id = Convert.ToInt32(myButton.CommandArgument);
}
}
The sender holds a reference to the LinkButton that triggered the event handler.
You can cast the object into a LinkButton and then retrieve its CommandArgument and cast that into an int.