<div>
<asp:GridView ID="gv" DataKeyNames="id" runat="server" SkinID="gvSkinSmall"
AutoGenerateColumns="false" AllowPaging="false" AllowSorting="false">
<Columns>
<asp:BoundField DataField="id" HeaderText="InOutSet_Definition_Id" Visible="true" />
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="txtName" runat="server" MaxLength="40" Text='<%# eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IsDelete">
<ItemTemplate>
<asp:TextBox ID="txt1" MaxLength="40"
runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle BackColor="Silver" />
</asp:GridView>
</div>
<div>
<asp:LinkButton CssClass="button" ID="btnSave" runat="server">
<span runat="server" id="spBtnSave" style="width: 60px; text-align: center">Save
</span>
</asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" CssClass="button">
<span runat="server" id="spBtnCancel" style="width: 60px; text-align: center">Cancel
</span>
</asp:LinkButton>
</div>
and before bind to grid delete rows where isdelete=false as:
for (int i=0; i<dt.Rows.Count; i++)
{
if (dt.Rows[i]["isdelete"].ToString() == 'false")
{
dt.Rows[i].Delete();
}
}
and for saving data to database see:
protected void Button1_Click(object sender, EventArgs e)
{
for (int count = 0; count < GridView1.Rows.Count; count++)
{
//you can get the bound filed values like
string strId = GridView1.Rows[count].Cell[0].Text;
//to get the template field value
TextBox tx1 = (TextBox)GridView1.Rows[count].FindControl("txt1");
string str1 = tx1.Text;
//you can insert the values here
}
}