I have Gridview full with data and I need when some of rows are checked i can be able to press the button and change the data accordingly, I can do it when all rows are checked but i can't find a way to connect my queries with id of one or many rows.
protected void UsedForButton_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { var chk = row.FindControl("InStockCbx") as CheckBox;
if (chk.Checked)
{
//using (WorkDBEntities db = new WorkDBEntities())
//{
// WorkTable table = new WorkTable();
// table.InStock = 0;
// db.WorkTables.Add(table);
// db.SaveChanges();
//}
string query = "UPDATE WorkTable SET InStock = 0 WHERE Id = " ???;
SqlCommand comm = new SqlCommand(query, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
}
Aucun commentaire:
Enregistrer un commentaire