首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

为啥gridview中RowUpdating方法执行后数据没变

2012-12-25 
为什么gridview中RowUpdating方法执行后数据没变?protected void GridView2_RowUpdating(object sender, G

为什么gridview中RowUpdating方法执行后数据没变?
        protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {   string sqlstr = "update ylcdxq set ylcd='"
            + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + "',cs="
            + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim() + ",jddj="
            + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim() + " where ylcd='"
            + ylcd.ToString() + "' and jh='" + jh + "' and sjrq=to_date('" + sjrq + "','yyyy-mm-dd')";
            Response.Write(sqlstr);
            ora_db.NoreturnSql(sqlstr);
            GridView2.EditIndex = -1;
            bind();
         }
GridView2.DataKeyNames是ylcd,我用Response.Write(sqlstr)显示出的ylcd、cs、jddj是没改变之前的,我是新手请多多帮助!!!谢谢!
[解决办法]
点击其他的ylcd的值都不变吗?

ylcd.ToString() 改成GridView1.DataKeys[e.RowIndex].Value.ToString() 
参考
http://blog.csdn.net/21aspnet/article/details/1540301 看来你就会了。


热点排行