<asp:LinkButton ID="LinkButton2" runat="server" CommandArgument=''<%# Eval("NewsID") %>'' CommandName="Del" OnClientClick="return confirm(''确认删除吗?'')">删除</asp:LinkButton>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Del")
{
string sql = "delete from News where NewsID=" + e.CommandArgument.ToString();
i = DBHelp.ExecuteSql(sql);
GridBind();
}
}
<asp:CommandField ShowDeleteButton="True" HeaderText=”操作”/>
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string NewsID = ((GridView)sender).DataKeys[e.RowIndex].Value.ToString();
string sql = "delete from News where NewsID=" + NewsID;
int i = DBHelp.ExecuteSql(sql);
GridBind();
}
</asp:TemplateField>
<asp:TemplateField HeaderText="操作" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton5" runat="server" CausesValidation="False"
CommandName="Delete" Text="删除" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</asp:TemplateField>
<asp:TemplateField HeaderText="操作" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton5" runat="server" CausesValidation="False"
CommandName="Delete" Text="删除" OnClientClick="return confirm(''确认要删除吗?'')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>