首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

DataGrid解决思路

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

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 ")
{
//
}
}

热点排行