Solved

Nested repeater inside another nester repeater

Posted on 2006-11-28
5
733 Views
Last Modified: 2008-01-09
Hi Experts,

I am trying to build a comments report wich is 3 levels deep. The top level is the 'Department' next level is the 'department's comments' then finally, the 'Products' that the comments was assigned.

For this I have a repeater that brings up a list of departments for a given date range that have comments, then I have a nested repeater to show the comments for each department. Now I need a 3rd repeater that will show the products for the comments since the customer service guys can select products and those get saved in a separate table that relates to the comment by comment and product ID.

For my first nested repeater I have this:

'Get the list of comments for the given department
    Protected Sub rpt_report_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpt_report.ItemDataBound

        'Get variables to send to stored proc
        Dim startDate As String = Request.Form("txt_dateStart")
        Dim endDate As String = Request.Form("txt_dateEnd")
        Dim depId As Integer = e.Item.DataItem("depId")

        'Attach datasource to repeater
        Dim conn As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("conn"))
        conn.Open()

        'Call the stored procedure we need
        Dim sql As String = "exec sp_rpt_departments_10" & "'" & startDate & "'," & "'" & endDate & "'," & depId

        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        da = New SqlDataAdapter(sql, conn)
        da.Fill(ds)

        Dim nestedRpt As New Repeater
        nestedRpt = e.Item.FindControl("rpt_comments")

        'Find nested repeater
        If ds.Tables(0).Rows.Count > 0 Then
            'Bind datasource
            nestedRpt.DataSource = ds.Tables(0)
            nestedRpt.DataBind()
        Else
            nestedRpt.Visible = False
        End If

        conn.Close()

    End Sub

That works just fine, my question is, how do I access the ItemDataBound event of the nested repeater so that I can give the 3rd repeater a datasource based on the row id from the second repeater.

Thanks in advance, I really need this one.

-Javier
0
Comment
Question by:jmar_click
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
kraffay earned 500 total points
ID: 18030268
Add this code to your class:

Protected WithEvents nestedRpt as Repeater

Then, on the ItemDataBound event of the master repeater, grab a handle to your nested repeater:

nestedRepeater = rpt_report.FindControl("nestedRepeater") -- <!-- this code is questionable, without seeing your markup, I can't know the exact syntax.

Once you have a handle to your repeater, you can dynamically set its datasource.
0
 
LVL 3

Author Comment

by:jmar_click
ID: 18030365
I have the first nested repeater working.

heres a breakdown of the way the repeaters are set up

master repeater = rpt_report
->first nested repeater = rpt_comments (nested inside rpt_report)
--> --> 2nd nested repeater = rpt_departments (nested inside rpt_comments)

nestedRpt = e.Item.FindControl("rpt_comments") <-- works fine to find the rpt_comments nested repeater. But maybe there is a better way.

Where do I add Protected WithEvents nestedRpt as Repeater, at the top of the class?
0
 
LVL 9

Expert Comment

by:kraffay
ID: 18030390
Yes, and the declaration at the top of the class
0
 
LVL 3

Author Comment

by:jmar_click
ID: 18030456
That didn't work, but I think you gave me a lead to something that might work. I was getting an error:
 Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

But the Protected WithEvents rpt_comments As Repeater    fixed that, i may be able to directly use the rpt_comments_ItemDataBound event for the nested repeater now. Let me try it
0
 
LVL 3

Author Comment

by:jmar_click
ID: 18030599
It didn't work. I don't get an error, but the ItemDataBound event for the nested repeater never fires.

Can you give me a bit more explanation on your suggestion please?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question