在我粘贴在网格下方的代码中,可以选择在单击删除按钮时删除该行。在点击服务器端代码之前,我想确认用户删除记录。
但总是命中服务器端代码,而不是首先显示确认弹出窗口。
<asp:GridView ID="grdDelegateList" runat="server" CssClass="gridviewBorder" AutoGenerateColumns="False"
CellPadding="1" Style="margin-left: 0px" BackColor="White" Font-Names="Calibri"
BorderWidth="1px" Width="100%" AllowPaging="True" GridLines="Horizontal" RowHoverBackColor="#666666"
RowHoverForeColor="White" SelectedRowStyle-BackColor="#333333" SelectedRowStyle-ForeColor="White"
PageSize="10" OnPageIndexChanging="grdDelegateList_PageIndexChanging" OnRowCommand="grdDelegateList_RowCommand"
OnRowDataBound="grdDelegateList_RowDataBound" OnRowDeleting="grdDelegateList_RowDeleting">
<Columns>
<asp:BoundField HeaderText="Employee ID" DataField="DelegateID" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
<asp:TemplateField HeaderText="Full Name" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<p>
<%#DataBinder.Eval(Container.DataItem, "Owner.FirstName")%>
<%#DataBinder.Eval(Container.DataItem, "Owner.LastName")%>
</p>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remove" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<span style="cursor: pointer">
<asp:LinkButton ID="ImgRemove" runat="server" CommandName="Delete" CommandArgument='<%# Eval("ID") %>'
Text="Remove" OnClientClick="return confirm(Are you sure you want to remove this Delegate);">
</asp:LinkButton></span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我想要做的是显示一个确认框,如果用户按下按钮服务器端代码(即:行命令)事件应该被击中,否则取消它应该什么都不做。但它不工作。