索引超出范围.必须为非负值并小于集合大小. 参数名: index
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string sqlstr = "delete from details where bookdate='" + GridView1.DataKeys[e.RowIndex].Values[0].ToString() + "'";
sqlcon = new SqlConnection(strCon);
sqlcom = new SqlCommand(sqlstr, sqlcon);
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcon.Close();
bind();
sqlcon = new SqlConnection(strCon);
string bkd = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("bookdetail")).Text;
string sqlm1 = "select T1 from book where booktime='" + GridView1.DataKeys[e.RowIndex].Values[0].ToString() + "' and T1='"
+ bkd + "'";
SqlCommand cmdm1 = new SqlCommand(sqlm1, sqlcon);
SqlDataReader drm1 = cmdm1.ExecuteReader();
if (drm1.Read())
{
string sqlstr1 = "update book set T1='8:30' where booktime='"
+ GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
sqlcom = new SqlCommand(sqlstr1, sqlcon);
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcon.Close();
GridView1.EditIndex = -1;
bind();
}
else
{
Response.Write("<script>alert('不能删除')</script>");
return;
}
{
string sqlstr = "delete from details where bookdate='" + GridView1.DataKeys[e.RowIndex].Values[0].ToString() + "'";
sqlcon = new SqlConnection(strCon);
sqlcom = new SqlCommand(sqlstr, sqlcon);
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcon.Close();
bind();
sqlcon = new SqlConnection(strCon);
string bkd = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("bookdetail")).Text;
string sqlm1 = "select T1 from book where booktime='" + GridView1.DataKeys[e.RowIndex].Values[0].ToString() + "' and T1='"
+ bkd + "'";
SqlCommand cmdm1 = new SqlCommand(sqlm1, sqlcon);
SqlDataReader drm1 = cmdm1.ExecuteReader();
if (drm1.Read())
{
string sqlstr1 = "update book set T1='8:30' where booktime='"
+ GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
sqlcom = new SqlCommand(sqlstr1, sqlcon);
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcon.Close();
GridView1.EditIndex = -1;
bind();
}
else
{
Response.Write("<script>alert('不能删除')</script>");
return;
}
...全文
相关推荐
电子商务购物商城前台
这是我自己写的一个电商前台类,一直报C#索引超出范围。必须为非负值并小于集合大小。参数名: index的错,望大神们私聊我帮助我解决问题,有重谢
Android应用因索引超出范围问题而崩溃。 请帮我解决这个问题
Android仍基于Java语言,因此例外通常是应用程序中以Java为主题的问题。 “索引超出范围”表示您正在尝试引用当前集合内不可用的元素。 看看异常本身,索引...
pandas中DataFrame修改index、columns名的方法示例
主要介绍了pandas中DataFrame修改index、columns名的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Python DataFrame 设置输出不显示index(索引)值的方法
今天小编就为大家分享一篇Python DataFrame 设置输出不显示index(索引)值的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
python 给DataFrame增加index行名和columns列名的实现方法
今天小编就为大家分享一篇python 给DataFrame增加index行名和columns列名的实现方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧


