注册 登录
编程论坛 ASP.NET技术论坛

删除提示问题

s6gy 发布于 2007-10-19 11:03, 714 次点击
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

//e.Rows[6].Cells[0].Attributes.Add("onclick", "return confirm('你确认要删除')");
e.Row.Cells[0].Attributes.Add("onclick", "return confirm('你确认要删除')");


}
这个事件中 如果Cells[0] 是没有错的
但是Cells[1] 或者其他的 2 3 4 5 就回出错提示
9 回复
#2
s6gy2007-10-19 11:04
{"指定的参数已超出有效值的范围。\r\n参数名: index"}

事实上我已经有8 列 至少
Cells[7] 撒
#3
jxnuwy042007-10-19 11:23
确认删除就是要这一行代码就够了,你确认按钮放在第几列那方括号里面的数字就第几个列的数字减1
e.Row.Cells[0].Attributes.Add("onclick", "return confirm('你确认要删除')");
#4
s6gy2007-10-19 11:38
就是啊我确认 按钮 放在第八行应该是
e.Row.Cells[7].Attributes.Add("onclick", "return confirm('你确认要删除')");
但是出错了 说 confirm
{"指定的参数已超出有效值的范围。\r\n参数名: index"}
#5
jxnuwy042007-10-19 11:42
这样看看:
加个判断
if (e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)(e.Row.Cells[2].Controls[0])).Attributes.Add("onclick", "return confirm('你确认要删除')");
}
#6
s6gy2007-10-19 12:14
结果是一样的
#7
bygg2007-10-19 12:28
用.e.rowindex
#8
jxnuwy042007-10-19 13:20
如果删除按钮在第一列的话这样写是没错的啊,至少确认删除这个事件没有错啊!(点一下删除会弹出一个对话框啊)至于点击确定按钮后出现的错误不是这里的问题。
e.Row.Cells[0].Attributes.Add("onclick", "return confirm('你确认要删除')");
#9
jxnuwy042007-10-19 13:23
如果一直有问题还是有问题绝对是你在判断列的时候出了问题(从0开始算)
#10
冰彩虹2007-10-19 19:38
debug
1