复制代码 代码如下:

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�Z句'”;

        sqlcom = new SqlCommand(sqlstr, sqlcon);

        sqlcom.ExecuteNonQuery();

        sqlcon.Close();

        GridView1.EditIndex = -1;

        bind();

    }

取列的值�樵��淼模�并不是更新后的,原因是因��Page_Load中加�d了���,每次更新后��自�铀⑿拢�所以需在Page_Load中判�嘁幌率欠褚趁婊卮�,再加�d,如下

复制代码 代码如下:

 protected void Page_Load(object sender, EventArgs e)

    {

        if (!Page.IsPostBack)

        {

            bind();

        }

    }

声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。