((LinkButton)(e.Row.Cells[5].Controls[0])).Attributes.Add("onclick","return confirm('你确认删除吗?');");
错误提示:Specified argument was out of the range of valid values.
Parameter name: index

解决方案 »

  1.   

    e.Row.Cells[5].Controls[0]检测这几个数字是否超出范围
      

  2.   

    ((LinkButton)e.Row.Cells[5].Controls[0]).Attributes.Add("onclick", "return confirm('你确认删除吗?');"); 
    括号引起的问题,修改之后建议先检查一下e.Row.Cells[5]里有几个控件,如果不是只有一个且第一个控件不是LinkButton的话还是会错的
      

  3.   

    模板列而且只有一个linkButton的话一般应该是Controls[1]。
      

  4.   

    在gridview控件中一共有六列,其中第六列中有一个linkbutton控件为删除按钮