If you are using dynamic SQL by building it in the application, you can do something like this; however, this will only work setting the state_p to 1. You will need to also put in code to reverse. What if the state_p is one, but needs to be zero (unchecked).
** Use this only to step through to see how the code is building the data for the where clause. To properly execute any SQL should be to build a list of values and pass those values to a method, which executes a stored procedure or function on the database server. **
StringBuilder sql = new StringBuilder();
sql.Append(" UPDATE <TABLE>");
sql.Append(" SET state_p = 1 ");
sql.Append(" WHERE id IN ("
foreach (GridViewRow gvr in GridView1.Rows)
{
if (((CheckBox)gvr.FindControl("CheckBox1")).Checked == true)
{
string data;
data = gvr.Cells[0].Text;
sql.Append(data + ",");
DropDownList1.Items.Add(data);
}
}
string exeSql = sql.ToString().Substring(0, sql.Length - 1) + ")";