Here is how to clear controls in GridView row using delete. Be careful that GridViewDeleteEventArgs is not GridViewDeletedEventArgs!
<asp:GridView ID="gvStolenStatusInfo" runat="server" AutoGenerateColumns="false" AllowPaging="true"
EmptyDataText="No records found." PageSize="10" CssClass="gridView"
OnRowDeleting="gvStolenStatusInfo_RowDeleting" AutoGenerateDeleteButton="true">
<Columns>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:TextBox ID="txtuCode" runat="server" Text='<%# Bind("Code") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comment">
<ItemTemplate>
<asp:TextBox ID="txtuComment" runat="server" Text='<%# Bind("Comment") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Notice the OnRowDeleting set to x_RowDeleting function and AutoGenerateDeleteButton. Now for the delete function:
protected void gvStolenStatusInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int rowID = e.RowIndex;
((TextBox)gvStolenStatusInfo.Rows[rowID].FindControl("txtuCode")).Text = string.Empty;
((TextBox)gvStolenStatusInfo.Rows[rowID].FindControl("txtuDate")).Text = string.Empty;
}
References:
http://www.codeproject.com/KB/webforms/Editable_GridView.aspx
2 comments:
Good dispatch and this post helped me alot in my college assignement. Gratefulness you as your information.
Opulently I to but I dream the post should secure more info then it has.
Post a Comment