我在datagrid中绑定了一列按扭,请问应该在哪里设定这组按钮的事件呢?

解决方案 »

  1.   

    参考:
    private void DataGrid_ItemCommand(object source, DataGridCommandEventArgs e) {
    if(e.CommandSource is Button){
    此外写上相应的处理的代码.
    }
    }
      

  2.   


    private void DataGrid_ItemCommand(object source, DataGridCommandEventArgs e) {
    if(e.CommandSource is Button){
       switch(((Button)e.CommandSource).ID){
             case "Delete":
             此外写上相应的处理的代码;
             break;
             case "Insert":
             此外写上相应的处理的代码;
             break;
             default:
             break;
             }
    }
    }
      

  3.   

    再页面中,设置button commandname 属性,private void DataGrid_ItemCommand(object source, DataGridCommandEventArgs e) 
    {
    if(e.commandname=="")
    {}
    }
      

  4.   

    可以在页面代码上,某个按钮里写 OnClick="方法名",然后在代码里写Protected void 方法名(EventArgs e)
      

  5.   

    呵呵,首先问一下楼主,试下CancelCommand事件,和UpdateCommand事件,也可以ItemDataCommand,不过得知道搂住的按钮是在模板列的还是按钮列?