In the GridView we can simply add a commandfield delete column to delete a row of information. However, in order to avoid misoperation caused by the deletion of the deletion, the operator to remove the operator to confirm, after the deletion.
First we add a template column to our GridView, as follows:
以下是引用片段:
<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 to the template column we added: onclientclick= "return confirm (' Confirm that you want to delete this message?"). '), as follows:
以下是引用片段:
<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('确认要删除此行信息吗?')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
Click Delete will be on the client before "confirm to delete?" dialog box, generally we confirm the deletion.