需要设置Web控件的CommandName,然后在 ItemCommand判断private void mainDataGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  {
     if(e.CommandName=="xxxx")
   {    ......
      }
   else if(e.CommandName=="xxxx")
   {
    ......   }
    
  }

解决方案 »

  1.   

    呵呵...这需要右键点击DataGrid1,选择<属性生成器>,选择<列>,添加<超级链接列>来解决这问题,不是在DataGrid1_SelectedIndexChanged事件里写...
      

  2.   

    是在datagrid的itemCommand事件里判断他的e.CommandName
      

  3.   

    编辑对应 EditCommand事件
    详细内容 对应SelectedIndexChanged区分开
      

  4.   

    为每个按钮列起个命令名字(属性生成器)
    然后在itemCommand事件里判断他的e.CommandName
    if(e.CommandName=="")
      

  5.   

    参考msdn的完整例子
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemWebUIWebControlsDataGridClassOnItemCommandTopic.htm