protected void Button3_Click(object sender, EventArgs e) { foreach(GridViewRow ro in GridView2.Rows) { foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { Label Role = (ro.Cells[1].FindControl("Role_Name") as Label); CheckBox chkAdd = (row.Cells[2].FindControl("CheckBox1") as CheckBox); CheckBox chkEdit = (row.Cells[2].FindControl("CheckBox2") as CheckBox); CheckBox chkView = (row.Cells[2].FindControl("CheckBox3") as CheckBox); CheckBox chkDelete = (row.Cells[2].FindControl("CheckBox4") as CheckBox); string strID = row.Cells[0].Text; string Pages = row.Cells[1].Text; string Role_Name = ro.Cells[2].Text; con.Open(); string query = "Insert Into Role1 ([Role_Name],[Add],[View],[Edit],[Delete]) values('"+Role_Name+"','"+(chkAdd.Checked== true?'Y':'N')+"','"+(chkView.Checked==true?'y':'N')+"' ,'"+(chkEdit.Checked==true?'y':'N')+"' ,'"+(chkDelete.Checked==true?'y':'N')+"') WHERE ID='" +strID + "' and Pages ='"+Pages+"'" ; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); BindGrid(); con.Close(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)