Hello, I have a datalist that will be used for online shopping. I have the product code and next to it a textbox for the user to enter the quantity of the respected product. By default, I show the product code and the textbox with the value of 1 in it. What I want to do is to add a linbutton next to the textbox so that, when the user enters a value different than 1 in the textbox, he will clicks on the button in order for me to store the new quantity value. But how will I know which product's the value the user changed when I have 5 products and I change the quantity value of one of them?
Add productId in linkbuttons 'commandArgument' property. Then in your onItemCommand event you can find ProductId from your CommandEventArgs (typically named by 'e'. like e.commandArgument) Linkbutton: <asp:LinkButton Visible="false" ID="managechecklist" Text="Update Value" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "productId") %>' Runat="server" /> HTML: And CodeBehind void Item_Command(Object sender, DataListCommandEventArgs e) { string productId = e.CommandArgument; } Code (markup):