+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Access parent repeater item from child repeater

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

    Access parent repeater item from child repeater

    hi, ok i got 2 repeaters:

    parent: rpActiveCategory
    child: rpActiveSubCategory

    now on my child's OnItemDataBound I need to access 'Eval("Name")' form the
    parent repeater.

    Also I am populating my child repeater from my parent OnIteDataBound.

    aspx.vb:
    Code:
    Protected Sub rpActiveCategory_OnItemDataBound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
    
                Dim Category As Category = e.Item.DataItem
    
                '---------------------------------------
                'populate rpActiveSubCategory
                Dim SubCategoryList As New SubCategoryList
                Dim myParams As New Params
    
                myParams.Activated = "true"
                myParams.Type = "interior"
                myParams.OrderBy = "ordered ASC"
                myParams.CategoryID = Category.Idkey
                SubCategoryList = SubCategoryManager.GetList(myParams)
    
                Dim rpActiveSubCategory As Repeater = e.Item.FindControl("rpActiveSubCategory")
    
                'bind data to repeater
                rpActiveSubCategory.DataSource = SubCategoryList
                rpActiveSubCategory.DataBind()
    
            End If
        End Sub
    
    Protected Sub rpActiveSubCategory_OnItemDataBound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                Dim SubCategory As SubCategory = e.Item.DataItem
    
                Dim lblActiveSubCategoryTitleText As New Label
                lblActiveSubCategoryTitleText.Text = SubCategory.Name
            End If
        End Sub
    
    anybody know how to do this, I did experiment with item.Parent, but no result
    I could of just been doing it wrong tho'

  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

    How exactly did you use e.Item.Parent? Like this?

    Code:
    e.Item.Parent.FindControl("yourControl")
    
    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

    well what i need to get is, the value "Name" from rpActiveCategory...

  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

    Try something like this:

    Code:
    e.Item.Parent.Parent.DataItem("Name")
    
    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

    err msg"
    Code:
    'DataItem' is not a member of 'System.Web.UI.Control'
    

  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

    whoops...take out the extra "Parent"
    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

    same error as before..

    my code:
    Code:
    Protected Sub rpActiveSubCategory_OnItemDataBound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                Dim SubCategory As SubCategory = e.Item.DataItem
    
                Dim strCategoryName As String = e.Item.Parent.DataItem("Name")
                Dim lblActiveSubCategoryTitleText As New Label
                lblActiveSubCategoryTitleText.Text = SubCategory.Name
            End If
        End Sub
    
    Shem

  8. #8
    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

    Alright, give this a try:

    Code:
    Dim rptItem As RepeaterItem = CType(e.Item.NamingContainer.NamingContainer, RepeaterItem)
    Dim strCategoryName As String = rptItem.DataItem("Name")
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    err msg:
    Code:
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.MissingMemberException: No default member found for type 'Category'.
    
    Source Error:
    
    Line 291:
    Line 292:            Dim rptItem As RepeaterItem = CType(e.Item.NamingContainer.NamingContainer, RepeaterItem)
    Line 293:            Dim strCategoryName As String = rptItem.DataItem("Name")
    Line 294:
    Line 295:            Dim lblActiveSubCategoryTitleText As New Label
    
    
    Source File: C:\inetpub\wwwroot\keithdesign\CustomControls\specs_interior.ascx.vb    Line: 293
    
    must be close to it now, atleast it picks up that the parent repeater is for Category...

  10. #10
    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

    If the data in the repeater is populated by your Business Objects, then you need to have something like this:

    Code:
    Dim rptItem As RepeaterItem = CType(e.Item.NamingContainer.NamingContainer, RepeaterItem)
    Dim test As MyClass = CType(rptItem, MyClass)
    Dim strCategoryName As String = test.Name
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. paging enabled in a repeater control
    By peebman2000 in forum .NET Development
    Replies: 6
    Last Post: September 4th, 2008, 12:15 PM
  2. convert repeater to pdf
    By peebman2000 in forum .NET Development
    Replies: 4
    Last Post: August 18th, 2008, 10:39 AM
  3. ModalPopup, Server Event, Repeater, Close ModalPopup
    By Shem in forum .NET Development
    Replies: 26
    Last Post: August 15th, 2008, 08:36 AM
  4. adding an event for my btnDelete in repeater
    By Shem in forum .NET Development
    Replies: 13
    Last Post: July 15th, 2008, 10:33 AM
  5. 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

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