protected void gvPopedom_RowDataBound(object sender, GridViewRowEventArgs e) { string adminid = Request.QueryString["AdminID"]; List <M_Popedom> listpopedom = new List <M_Popedom>(); listpopedom = B_Popedom.SelectPopedom(adminid); foreach (GridViewRow gvr in gvPopedom.Rows) { int classid = Convert.ToInt32(gvr.Cells[0].Text); foreach (M_Popedom popedom in listpopedom) { if (classid == popedom.Class_ID) { ((CheckBox)(gvr.FindControl("Popedom"))).Checked = true; } } // string classid = gvr.Cells[0].Text.ToString(); // if (B_Popedom.SelectPopedomClassID(adminid, classid)) // { // ((CheckBox)(gvr.FindControl("Popedom"))).Checked=true; // } } }