如何区分gridview中的两个《选择》按钮?
在gridview控件内定义了两个《选择》按钮:
<asp:CommandField SelectText="选择(修改)" ShowSelectButton="True" />
<asp:CommandField SelectText="选择(显示)" ShowSelectButton="True" />
在 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) 事件中如何判断当前按下了哪一个《选择》按钮。
在gridview控件内定义了两个《选择》按钮:
<asp:CommandField SelectText="选择(修改)" ShowSelectButton="True" />
<asp:CommandField SelectText="选择(显示)" ShowSelectButton="True" />
在 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) 事件中如何判断当前按下了哪一个《选择》按钮。
<asp:CommandField SelectText="选择(显示)" CommandName="select" ShowSelectButton="True" /> 在OnRowCommand事件中 if (e.CommandName == "update")
{
//业务代码
}
else if(e.CommandName == "select")
{
//业务代码
}
<asp:CommandField SelectText="选择(修改)" ShowSelectButton="True" />
中加入CommandName="update",改为:
<asp:CommandField SelectText="选择(修改)" CommandName="update" ShowSelectButton="True" />
提示错误为;
“属性CommandName不是CommandField的有效属性”
应该用<asp:ButtonField这个里面才有CommandName属性