| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1188 人关注过本帖
标题:GridView编辑操作在点更新时出现错误
只看楼主 加入收藏
zsqbctw
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-5-8
收藏
 问题点数:0 回复次数:0 
GridView编辑操作在点更新时出现错误
GridView编辑操作在点更新时出现错误
用户代码未处理 ArgumentOutOfRangeException
指定的参数已走出有效值的范围。
参数名:index
   protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string sqlstr = "update Vehicles set licence='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim().ToString() + "',vehicle_type='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim().ToString() + "',vehicle_brand='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.Trim().ToString() + "',Purchase_date='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.Trim().ToString() + "',Purchase_price="
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[7].Controls[0])).Text.Trim().ToString() + ",Initial_km='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[8].Controls[0])).Text.Trim().ToString() + "',Engine_num='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[9].Controls[0])).Text.Trim().ToString() + "',Frame_num='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[10].Controls[0])).Text.Trim().ToString() + "',Purchase_tax_num='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[11].Controls[0])).Text.Trim().ToString() + "',Theory_fuel_consumption='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[12].Controls[0])).Text.Trim().ToString() + "',Train_licence='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[13].Controls[0])).Text.Trim().ToString() + "',Branch='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[14].Controls[0])).Text.Trim().ToString() + "',Train_id='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[15].Controls[0])).Text.Trim().ToString() + "',Current_status='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[17].Controls[0])).Text.Trim().ToString() + "',Out_date='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[18].Controls[0])).Text.Trim().ToString() + "',vehicle_note='"
              + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[19].Controls[0])).Text.Trim().ToString() + "'where Registration_id='"
              + GridView1.DataKeys[e.RowIndex].Value.ToString()+ "'";

               try
         {
            
            if (sqlcon.State.ToString() == "Closed") sqlcon.Open();
             SqlCommand sqlcom = new SqlCommand(sqlstr, sqlcon);
             sqlcom.ExecuteNonQuery();
             sqlcon.Dispose();
            if (sqlcon.State.ToString() == "Open") sqlcon.Close();

             GridView1.EditIndex = -1;
             //GridViewBind();
         }
        catch (Exception ex)
         {
             Response.Write("数据库错误,错误原因:" + ex.Message);
             Response.End();
         }
     
     }
搜索更多相关主题的帖子: GridView编辑 licence vehicle sender TextBox 
2008-06-03 00:12
快速回复:GridView编辑操作在点更新时出现错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015270 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved