源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

GridView_RowUpdating取不到新值的解决方法

  • 时间:2020-03-16 21:12 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:GridView_RowUpdating取不到新值的解决方法
[u]复制代码[/u] 代码如下:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)     {         sqlcon = new SqlConnection(strCon);         sqlcon.Open();         string bianhao = Convert.ToString(this.GridView1.DataKeys[e.RowIndex].Value);         string beizhu = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString();         string sqlstr = "SQL語句'";         sqlcom = new SqlCommand(sqlstr, sqlcon);         sqlcom.ExecuteNonQuery();         sqlcon.Close();         GridView1.EditIndex = -1;         bind();     }
取列的值為原來的,并不是更新后的,原因是因為Page_Load中加載了數據,每次更新后會自動刷新,所以需在Page_Load中判斷一下是否页面回传,再加載,如下
[u]复制代码[/u] 代码如下:
 protected void Page_Load(object sender, EventArgs e)     {         if (!Page.IsPostBack)         {             bind();         }     }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部