Method of adding delete prompt box for GridView in ASP.NET
- 2021-06-28 12:14:08
- OfStack
This article provides an example of how to add a delete prompt box for GridView in ASP.NET.Share it for your reference.Specific analysis is as follows:
In GridView, we can add an CommandField delete column directly to delete a row of information.However, in order to avoid the mistaken deletion caused by misoperation, the deletion operator has to ask the operator to confirm, and then delete.
First we add a template column to our GridView as follows:
Here are the reference fragments:
<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 the template column we added: OnClientClick= "return confirm ('Are you sure you want to delete this line information?')".The following:
Here are the reference fragments:
<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 line? ')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
I hope that the description in this paper will be helpful to everyone's asp.net program design.