亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

GridView_RowUpdating取不到新值的解決方法

 更新時(shí)間:2013年05月23日 11:23:26   作者:  
GridView_RowUpdating取不到新值的解決方法,需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

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();
    }

取列的值為原來的,并不是更新后的,原因是因?yàn)镻age_Load中加載了數(shù)據(jù),每次更新后會(huì)自動(dòng)刷新,所以需在Page_Load中判斷一下是否頁面回傳,再加載,如下

復(fù)制代碼 代碼如下:

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bind();
        }
    }

相關(guān)文章

最新評(píng)論