using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class user_inbox : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void CheckBox2_CheckedChanged(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { var chk = GridView1.Rows[i].Cells[0].FindControl("chksender") as CheckBox; chk.Checked = chkheader.Checked; } } protected void chksender_CheckedChanged(object sender, EventArgs e) { bool flag = true; for (int i = 0; i < GridView1.Rows.Count; i++) { var chk = GridView1.Rows[i].Cells[0].FindControl("chksender") as CheckBox; if (chk.Checked == false) { flag = false; break; } } chkheader.Checked = false; } }