可以用按钮列或模版列,然后加入的按钮会有一个commandname属性。在itemcommand事件里:
if e.commandname="你在前面给按钮设的commandname" then
‘你的代码
end if

解决方案 »

  1.   

    先给button1加上commandname属性,然后再itemcommand事件中写代码
    If e.CommandName = button1的commandname名 Then
    end if
      

  2.   

    请问bestxjp(超蓝) ,commandname属性里面我添什么?itemcommand事件在哪?请说的详细些,谢谢~~我比较菜,呵呵!
      

  3.   

    先在dataGrid里设置button的commandname
    private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
        if( e.CommandName == "button的commandname" )
        {
             //加入你的代码
        }
    }