简体   繁体   中英

How to set accept in cell(2) after selecting in gridview?

I have to set status as accept, reject for customer,while registering status while be pending. I need, if condition for this, which row is selected then corressponding event should change in database as accept or reject.

protected void Button2_Click(object sender, EventArgs e)
{

    SqlCommand cmd = new SqlCommand("select * from Testing", OIMS_01);
    SqlDataAdapter ad = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();

    ad.Fill(ds);

    if (GridView1.SelectedRow != null)
    {
      ds.Tables(0).Rows(0).Item(0) = GridView1.SelectedRow.Cells(1).Text;
      ds.Tables(0).Rows(0).Item(1) = GridView1.SelectedRow.Cells(2).Text;
      ds.Tables(0).Rows(0).Item(2) = "Accept";

    }
    else
    {
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please select a row.')", true);
    }
    ad.Update(ds);
}
ds.Tables[0].Rows[0]["Your column name"] ="ACCEPT";

要么

ds.Tables[0].Rows[0][2] ="ACCEPT";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM