Pre render problem

2 posts, 1 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 31 Mar 2013 Link to this post

    Hi

    I have a pre render event to scan the header and turn off the select all checkbox.

    My pre render code looks like this:
    Protected Sub rgProcedures_PreRender(sender As Object, e As EventArgs) Handles rgProcedures.PreRender
     
        For Each HeaderItem As Telerik.Web.UI.GridHeaderItem In rgProcedures.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.Header)
            Dim chkSelectAll As CheckBox = DirectCast(HeaderItem("colClientSelect").Controls(0), CheckBox)
            chkSelectAll.Visible = False
        Next
     
     
    End Sub


    I have just added a <columnGroup> to combine a header over 2 columns and get the following error:

    Specified argument was out of the range of valid values.
    Parameter name: index


    At this line in my Pre render: Dim chkSelectAll As CheckBox = DirectCast(HeaderItem("colClientSelect").Controls(0), CheckBox)

    Any Ideas
  2. Answer
    Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 03 Apr 2013 Link to this post

    Hi,

    You need to modify your code as follows:

    Protected Sub rgProcedures_PreRender(sender As Object, e As EventArgs) Handles rgProcedures.PreRender
    For Each HeaderItem As Telerik.Web.UI.GridHeaderItem In rgProcedures.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.Header)
        For Each cell As TableCell In HeaderItem.Cells)
            If cell.Controls.Count > 0 Then
                Dim chkSelectAll As CheckBox = DirectCast(CellFindControl("CheckBoxID"), CheckBox)
                If chk IsNot Nothing Then
                    chkSelectAll.Visible = False
                End If
            End If
        Next
        Dim chkSelectAll As CheckBox = DirectCast(HeaderItem("colClientSelect").Controls(0), CheckBox)
        chkSelectAll.Visible = False
    Next
    End Sub

    Greetings,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top