+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 30

Thread: Select all checkboxes in child repeater

  1. #1
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    Select all checkboxes in child repeater

    hi guys

    i'm trying to select all checkboxes in a child repeater, but i am having some
    difficulty.

    I have a checkbox in my HeaderTemplate, that when clicked must check all
    checkboxes in my ItemTemplate, All of this is in a child repeater.

    here's the simplified aspx page:
    Code:
    <asp:Repeater id="rpActiveCategory" runat="server" OnItemDataBound="rpActiveCategory_OnItemDataBound">
    	<ItemTemplate>
    
    		<asp:Repeater ID="rpActiveSpecs" runat="server" OnItemDataBound="rpActiveSpecs_OnItemDataBound" OnItemCommand="rpActiveSpecs_OnItemCommand">
    			<headertemplate>
    				<asp:CheckBox ID="cbActiveMain" runat="server" OnCheckedChanged="OnCheckedChanged_cbActiveMain" AutoPostBack="true" />
    			</headertemplate>
    
                            <ItemTemplate>
    				<asp:CheckBox ID="cbActive" runat="server" Enabled="true" /> 
    And here is code for 'OnCheckedChanged_cbActiveMain':
    Code:
    Public Sub OnCheckedChanged_cbActiveMain(ByVal s As Object, ByVal e As EventArgs)
            Dim myCheckBox As CheckBox = s
            Dim rpActiveCategory As Repeater = myCheckBox.Parent.Parent.Parent.Parent.Parent
            Dim rpActiveCategoryItem As RepeaterItem = myCheckBox.Parent.Parent.Parent.Parent
            Dim rpActiveSpecs As Repeater = myCheckBox.Parent.Parent
            Dim rpActiveItem As RepeaterItem = myCheckBox.Parent
    
            Dim cbActiveMain As CheckBox = rpActiveItem.FindControl("cbActiveMain")
            Dim cbActive As CheckBox
    
            For Each categoryItem As RepeaterItem In rpActiveCategory.Items
                For Each item As RepeaterItem In rpActiveSpecs.Items
                    cbActive = rpActiveItem.FindControl("cbActive")
                    cbActive.Checked = True
                Next
            Next
        End Sub
    
    the prob is that my code can't reference cbActive? gives ma an Object Null Reference.

    any ideas, am i going about this in the right way?
    Shem

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Try accessing the Select All/Deselect All checkbox in the child repeater's RowDataBound Event.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    huh?

    cbActiveMain is the select all/deselect all checkbox, which i can access?
    cbActive are the checkboxes i can't access...

    i'm prob missing what your saying aren't I

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by Shem View Post
    i'm prob missing what your saying aren't I
    Maybe

    It should be easy to gain access to the checkboxes of the child repeater in its own RowDataBound event. Likewise, it should be easy to gain access to the other checkbox (Select All) from there, also.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  5. #5
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    er... ok then

    so when i check cbActiveMain i fire my event, and then how exactly am i to use
    the repeaters RowDataBound event?

    i'm a bit lost here...

  6. #6
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by Shem View Post
    and then how exactly am i to use
    the repeaters RowDataBound event?
    The same way you always use the RowDataBound event. Specifiy that the child repeater should use it on RowDataBound. Inside the event, use FindControl to gain access to the checkboxes within the child repeater and to gain access to the checkbox in the parent repeater.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  7. #7
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    cool gonna google it, never used it before so prob why i'm lost here

    thanks for the tip
    will let everyone know how it goes

    Shem

  8. #8
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    ok i think i get it...

    Could I also use my repeaters OnItemDataBound?
    after i fire my OnCheckedChanged event, I rebind my repeater
    and in my OnItemDataBound event i simply check if cbActiveMain is checked
    if it is, I simply check cbActive?

    Shem

  9. #9
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    lol sorry, that's what I meant to use, ItemDataBound...RowDataBound is for GridView
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  10. #10
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    Quote Originally Posted by jmurrayhead View Post
    lol sorry, that's what I meant to use, ItemDataBound...RowDataBound is for GridView
    lol, was wondering why there was no intellisense for RowDataBound with my repeater

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Select Top 100 Percent
    By Wolffy in forum SQL Development
    Replies: 2
    Last Post: December 12th, 2008, 06:19 AM
  2. Access parent repeater item from child repeater
    By Shem in forum .NET Development
    Replies: 10
    Last Post: September 9th, 2008, 06:03 AM
  3. Dynamic Checkboxes
    By Shem in forum .NET Development
    Replies: 9
    Last Post: August 27th, 2008, 10:02 AM
  4. Access 03 Adding updating data from child table to Parent
    By nboscaino in forum Microsoft Access
    Replies: 8
    Last Post: July 15th, 2008, 09:12 AM
  5. sQL select add '%' next to value
    By peebman2000 in forum SQL Development
    Replies: 8
    Last Post: March 28th, 2008, 11:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO