操作GridView中的命令按钮
/// <summary>
/// 每一行的Command命令
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gv1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int memberid = 0;
memberid = int.Parse(e.CommandArgument.ToString());
if (e.CommandName.ToString().Equals("DelCorporation"))
{
//这种情况要执行的操作
}
if (e.CommandName.ToString().Equals("ActCorporation"))
{
//这种情况要执行的操作
}
}
前台的命令按钮:
<asp:LinkButton ID="LinkButtonDel" runat="server" CommandName="DelCorporation" CommandArgument='<%#((DataRowView)Container.DataItem)["字段名"]%>' OnClientClick="return confirm('确定在执行该操作吗?');">删除</asp:LinkButton>
<asp:LinkButton ID="LinkButtonAct" runat="server" CommandName="ActCorporation" CommandArgument='<%#((DataRowView)Container.DataItem)["字段名"]%>' OnClientClick="return confirm('确定在执行该操作吗?');">启用</asp:LinkButton>