DirectCast(Page.FindControl("dgListItems"), DataGrid)>
CheckBox check = sender as CheckBox; if (check != null) check.Checked = true;If it's from some other event handler, or just in something like a normal postback, you can't do this directly. Actually, I don't think they expose a FindControl for that kind of thing (at least, I didn't see one). You could do this yourself though by traversing the Controls collection of the grid:
CheckBox check = this.FindGridControl(this.grdSample.Controls, "checkAll") as CheckBox; if (check != null) check.Checked = true; protected Control FindGridControl(ControlCollection control, string controlName) { Control matchingControl = null; foreach (Control subControl in control) { if (subControl.ClientID.EndsWith(controlName)) return subControl; matchingControl = this.FindGridControl(subControl.Controls, controlName); if (matchingControl != null) break; } return matchingControl; }