Hello all,
I have taken a gridview in web form and binded it with a data table. Every time I click a add button a new row is added to gridview. So far so good, but I have a problem while editing | deleting.
I am not getting anything working when I click Edit or Remove button in grid view.
<asp:GridView ID="gvCustom" runat="server" CssClass="Gridview" AutoGenerateColumns="false" Width="100%"><Columns><asp:BoundField DataField="Name" HeaderText="Name" /><asp:BoundField DataField ="Value" HeaderText="Value" /><asp:CommandField ButtonType="Button" ShowEditButton="True" DeleteText="Remove" ShowDeleteButton="True" CancelText="Cancel" /></Columns></asp:GridView><asp:TextBox ID="txtName" runat="server" ToolTip="Enter Name" Width="46%" Height="25px"></asp:TextBox><asp:TextBox ID="txtValue" runat="server" ToolTip="Enter Value" Width="46%" Height="25px"></asp:TextBox><asp:Button ID="btnAdd" runat="server" Text="Add" CausesValidation="false" onclick="btnAdd_Click" />
in code behind gridview is binded to a datatable.
DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("Value"); dt.Rows.Add(txtName.Text, txtValue.Text); gvCustom.DataSource = dt; gvCustom.DataBind();
Now please tell me how its Edit & Delete can work?
Thanks