日期:2014-05-19  浏览次数:20976 次

DataGrid
在DataGrid中模版列中放一个按钮,可以响应itemcommand事件,如果现在有两个按钮,怎么区分,我单击的是哪一个呢

------解决方案--------------------
<asp:button commandname= "button1 " ID= "button1 " runat= "server " /> //第一个按钮
<asp:button commandname= "button2 " ID= "button2 " runat= "server " /> //第二个按钮

事件
itemcommand中:
if(e.commandname== "button1 ") //单击第一个按钮的事件
{
//.....
}
if(e.commandname== "button2 ") //单击第二个按钮的事件
{
//.....
}


以上为手写,有书写错误自己纠正
------解决方案--------------------
commandname
------解决方案--------------------
根据按钮的CommandName

private void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
if(e.CommandName == "XXX ")
{
//
}
else(e.CommandName == "YYY ")
{
//
}
}