This is probably not the best, but the option is to set the primary key of your table as a DataKey GridView, then iterate over the grid and use the datakey value and the edited value to update the database. Here is an example.
<asp:GridView ID="GridView1" runat="server" DataKeyNames="ID"> <Columns>..... foreach (var item in GridView1.Items) { var id = (Guid)GridView1.DataKeys[item.DataItemIndex].Value; var txt= item.FindControl("AmountTextBox") as Textbox; if (cb != null && id.HasValue) UpdateRow(id.Value, txt.Text); }
alejandrobog
source share