DirectCast(Page.FindControl("dgListItems"), DataGrid)>>
>CheckBox check = sender as CheckBox; >if (check != null) > check.Checked = true; >>
>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; >} >Hi Paul
Dim chkTemp As CheckBox = DirectCast(Me.FindMyControl(DirectCast(dgTemp, Control), "checkAll"), CheckBox) If Not chkTemp Is Nothing Then chkTemp.Checked = False End If
Private Function FindMyControl(ByRef ControlToSearch As Control, _ ByVal controlID As String) As Control Dim matchingControl As Control = Nothing Try For Each subControl As Control In ControlToSearch.Controls If ((Not subControl.ID Is Nothing) AndAlso (subControl.ID.EndsWith(controlID))) Then matchingControl = subControl Exit For Else If (Not matchingControl Is Nothing) Then 'found it Exit For ElseIf subControl.HasControls() Then matchingControl = Me.FindMyControl(subControl, controlID) End If End If Next Catch objEx As Exception Finally FindMyControl = matchingControl End Try End Function