ASP.net报错提示:指定的参数已超出有效值的范围。参数名: index!

publicpartialclassAdmin_Seeadmin:System.Web.UI.Page{DBCC=newDB();publicvoidBin(){SqlC... public partial class Admin_Seeadmin : System.Web.UI.Page
{
DB CC = new DB();
public void Bin()
{
SqlConnection myConn = CC.Getconnection();
myConn.Open();
string sqlStr = "select * from User_tb ";
SqlDataAdapter myDa = new SqlDataAdapter(sqlStr, myConn);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
GridView1.DataSource = myDs;
GridView1.DataKeyNames = new string[] { "UserID" };
GridView1.DataBind();
myConn.Close();

}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bin();
}
}
protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
{
CC.ExecSQL("delete from User_tb where UserID='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'");
Bin();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)(e.Row.Cells[4].Controls[0])).Attributes.Add("onclick", "return confirm('确定要删除吗?')");
}
}
}
添加这个事件就报错:GridView1_RowDataB
展开
 我来答
百度网友f4c2828
2011-11-20 · TA获得超过181个赞
知道小有建树答主
回答量:362
采纳率:0%
帮助的人:138万
展开全部
应该是这句话错,((LinkButton)(e.Row.Cells[4].Controls[0])).Attributes.Add("onclick", "return confirm('确定要删除吗?')");
看看你的删除按钮在哪一列上
liulvhe
2011-11-21
知道答主
回答量:26
采纳率:0%
帮助的人:17.8万
展开全部
你确定你绑定的linkbutton是在第5列吗?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
Damon_lan
2011-11-20 · TA获得超过2054个赞
知道小有建树答主
回答量:415
采纳率:0%
帮助的人:175万
展开全部
程序没有问题,急跟踪一下!!~。它执行到哪一步开始出错?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式