在VS2005中
我的GridView 绑定的顺序是这样的
第一列   第二列  第三列  第四列 用户名    密码    编辑    删除        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ((LinkButton)(e.Row.Cells[3].Controls[0])).Attributes.Add("onclick", "return confirm('你确定要删除码?');");
            }
        }上面的这句可以实现删除时提示 但是点击编辑的时候 就包这样的错误 请问怎么解决啊 是不是点击编辑的时候e.Row.Cells[3].Controls[0]的值就改动了啊?

解决方案 »

  1.   

    e.Row.Cells[3]这就是表示第四列
    点击编辑也弹出confirm?
      

  2.   

    <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
                                Text="删除" OnClientClick="return confirm('确定要删除???')"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
      

  3.   

    包这个错误 指定的参数已超出有效值的范围。
    参数名: index
      

  4.   

    什么样的错误?
     ((LinkButton)(e.Row.Cells[3].Controls[0])).Attributes.Add("onclick", "JavaScript:return confirm('你确定要删除码?');");
      

  5.   

    我lz我点击 删除的时候 有弹出 "你确定删除吗?" 的脚本 我点击确定就删除了 证明我脚本没有问题啊就是点击编辑的时候报错指定的参数已超出有效值的范围。
    参数名: index