ASP. NET adds the deletion prompt box for the GridView, asp. netgridview
This example describes how to add and delete a prompt box for the GridView in ASP. NET. Share it with you for your reference. The specific analysis is as follows:
In the GridView, we can directly add a CommandField deletion column to delete a row. However, in order to avoid accidental deletion due to misoperations, the operator is asked to confirm the deletion before deletion.
First, we add a template column to our GridView, as shown below:
The following is a reference clip:
<ASP:TemplateField HeaderText="Delete" ShowHeader="False"> <ItemStyle ForeColor="Red" /> <ItemTemplate> <asp:LinkButton ID="BtnDelete" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton> </ItemTemplate> </asp:TemplateField>
Next, we add OnClientClick = "return confirm ('Are you sure you want to delete this row? ') ", As follows:
The following is a reference clip:
<Asp: TemplateField HeaderText = "Delete" ShowHeader = "False"> <ItemStyle ForeColor = "Red"/> <ItemTemplate> <asp: linkButton ID = "BtnDelete" runat = "server" CausesValidation = "False" CommandName = "Delete" Text = "Delete" OnClientClick = "return confirm ('Are you sure you want to Delete this row information? ') "> </Asp: LinkButton> </ItemTemplate> </asp: TemplateField>
I hope this article will help you design your asp.net program.