void BindData()
    {
        string sql = "select top 10 ID,jobno,jobfixno,jobtype from jobse";
        SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
        DataSet ds = new DataSet();
        myda.Fill(ds, "RusTable");
        GridView1.DataSource = ds.Tables["RusTable"].DefaultView;
        GridView1.DataBind();
        conn.Close();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
    }

    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        BindData();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox tb = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox001");
        string dkvalue = GridView1.DataKeys[e.RowIndex].Value.ToString();
        string sql1 = "update jobse set jobno='" + tb.Text.ToString() + "' where id='" + dkvalue + "'";
        conn.Open();
        SqlCommand cmd = new SqlCommand(sql1, conn);
        cmd.ExecuteNonQuery();
        conn.Close();
        GridView1.EditIndex = -1;
        BindData();
    }

相关文章:

  • 2021-08-30
  • 2022-01-04
  • 2022-12-23
  • 2022-02-12
  • 2021-04-11
  • 2021-12-11
  • 2021-07-11
  • 2022-01-06
猜你喜欢
  • 2022-01-23
  • 2022-01-13
  • 2021-10-02
  • 2021-10-07
  • 2022-12-23
  • 2021-09-05
  • 2022-01-13
相关资源
相似解决方案