首页 新闻 会员 周边 捐助

索引超出范围。必须为非负值并小于集合大小。

1
[已关闭问题] 关闭于 2012-07-21 23:47
 1  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 2     {
 3         SqlConnection con = new SqlConnection("server=DULI-PC;database=Study_NET;uid=sa;pwd=");
 4         con.Open();
 5         string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
 6         string pro_name = ((TextBox)this.GridView1.Rows[e.RowIndex].FindControl("tname")).Text.ToString();
 7         string pro_type = ((TextBox)this.GridView1.Rows[e.RowIndex].FindControl("ttype")).Text.ToString();
 8         string pro_money = ((TextBox)this.GridView1.Rows[e.RowIndex].FindControl("tmoney")).Text.ToString();
 9         string pro_content = ((TextBox)this.GridView1.Rows[e.RowIndex].FindControl("tcontent")).Text.ToString();
10         string cmdtext = "update product set pro_name='" + pro_name + "',pro_type='" + pro_type + "',pro_money='" + pro_money + "',pro_content='" + pro_content + "' where pro_id='" + id + "'";
11         SqlCommand cmd = new SqlCommand(cmdtext, con);
12         cmd.ExecuteNonQuery();
13         this.GridView1.EditIndex = -1;
14         band();
15         Response.Write("<script>alert('更新成功!!')</script>");
16 
17     }

 

 

索引超出范围。必须为非负值并小于集合大小。
参数名: index

行5:         int id = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value.ToString());

doubledu的主页 doubledu | 初学一级 | 园豆:199
提问于:2012-07-21 23:43
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册