protected void Button7_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { if (Session["Role_Name"] != null && !string.IsNullOrEmpty(Session["Role_Name"].ToString())) { CheckBox chkAdd = (row.Cells[1].FindControl("CheckBox1") as CheckBox); CheckBox chkEdit = (row.Cells[2].FindControl("CheckBox2") as CheckBox); CheckBox chkView = (row.Cells[3].FindControl("CheckBox3") as CheckBox); CheckBox chkDelete = (row.Cells[4].FindControl("CheckBox4") as CheckBox); // string strID = row.Cells[0].Text; string Pages = row.Cells[0].Text; con.Open(); string query = "Update Role1 set [Add]='" + (chkAdd.Checked == true ? 'Y' : 'N') + "', [View]='" + (chkView.Checked == true ? 'y' : 'N') + "' ,[Edit]='" + (chkEdit.Checked == true ? 'y' : 'N') + "' ,[Delete]='" + (chkDelete.Checked == true ? 'y' : 'N') + "' where Pages ='" + Pages + "' and Role_Name='" + Session["Role_Name"].ToString() + "'"; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); populateGridview(); con.Close(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)