CommandName与CommandArgument
当网页上具有多个Button控件时,多个Button控件又处理单个事件,可以标记按钮,使代码根据窗体上被单击的按钮进行逻辑判断,这样的Button按钮没有OnClick事件,用Button_Command事件代替。
命令的附加信息可以使用CommandArgument属性来指定,可以用CommandArgument来精确定义需要的参数值
<asp:LinkButton ID="lbtnDel" CommandName="del" CommandArgument='<%#Eval("userid") %>' runat="server">删除</asp:LinkButton></td>
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.ToString() == "del")
{
new BLL.usersBLL().Deleteusers(int.Parse(e.CommandArgument.ToString()));
ShowData();
}
}