I have a webpage in aspx format that features a gridview containing three fields and an "Update" button. Upon clicking the Update button, I am redirected to another aspx page with a form displaying more details about the selected entry from the grid view. This form includes additional fields and a "Delete" button. Upon clicking the Delete button, my objective is to close the current form and return to the gridview to delete the corresponding entry. In implementing this functionality, I have utilized TemplateField within my gridview.
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField ShowHeader="False" HeaderText=" ">
<ItemTemplate>
<asp:Button ID="Btn_Update" Text="Update" runat="server" ButtonType="Button" CommandName="update" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="FirstName" HeaderText="First Name" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" />
</Columns>
</asp:GridView>
Following the closure of the form upon selecting the "Delete" button, the following code snippet details how I handle returning back to the gridview:
protected void btn_Delete_Click(object sender, EventArgs e)
{
#region Redirect to Page
Page.ClientScript.RegisterStartupScript(this.GetType(), "RefreshParent", "<script language='javascript'>RefreshParent()</script>");
Response.Write("<script>window.close();</" + "script>");
#endregion
ClearData();
}
I would greatly appreciate assistance on how to effectively remove the row from the gridview after executing the "Delete" action in the form. Thank you for your support!