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
Solved

Inner Repeater not displaying data

Posted on 2007-04-03
8
570 Views
Last Modified: 2008-01-09
I have a page with an outer Repeater and an inner Repeater.

The behind code is in VB.NET.

The outer Repeater is executing just fine, but the inner repeater does not display any data.

I have confirmed that there is data there for it to display.

Here is my code:
aspx.vb:
Protected Sub LoadData()
        Dim conn As New SqlConnection
        Dim cmd As New SqlCommand
        Dim connstring As String
        Dim da As New SqlDataAdapter
        Dim dt As New DataTable
        Dim ds As New Data.DataSet

        connstring = Connector.ConnectStringBuild
        conn.ConnectionString = connstring
        cmd.Connection = conn
        cmd.CommandText = "ACT_GET_COLLECTION_DETAILS"
        cmd.CommandType = CommandType.StoredProcedure


        cmd.Parameters.Add("@SERVICE_ID", SqlDbType.Int).Value = SetVars.Service_ID
        cmd.Parameters.Add("@LOGON_NAME", SqlDbType.VarChar).Value = SetVars.UserName
        cmd.Parameters.Add("@INDICATOR", SqlDbType.VarChar).Value = SetVars.Indicator

        conn.Open()
        da.SelectCommand = cmd
        da.Fill(ds, "ACT_COLLECTION")

        conn.Close()

        cmd.CommandText = "ACT_GET_FUNCTION_SERVICE_DETAILS"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Clear()
        cmd.Parameters.Add("@GROUP_NAME", SqlDbType.VarChar).Value = SetVars.GroupName
        cmd.Parameters.Add("@SERVICE_ID", SqlDbType.Int).Value = SetVars.Service_ID
        cmd.Parameters.Add("@OBJECT_NAME", SqlDbType.VarChar).Value = "COLLECTION"
        'cmd.Parameters.Add("@COLLECTION_ID", SqlDbType.Int).Value = 7

        conn.Open()
        Dim da1 As New SqlDataAdapter
        da1.SelectCommand = cmd
        da1.Fill(ds, "ACT_PERMISSION")

        ds.Relations.Add("COLLECTION_ID_Relation", ds.Tables(0).Columns("COLLECTION_ID"), ds.Tables(1).Columns("COLLECTION_ID"))

        Me.ParentRepeater.DataSource = ds.Tables(0)
        Me.ParentRepeater.DataBind()
        conn.Close()




    End Sub

asp:
<asp:Repeater ID="ParentRepeater" runat="server">
        <HeaderTemplate>
        <table style="LEFT: 178px; WIDTH: 980px; POSITION: absolute; TOP: 195px" id="DataTable">
        <tr>
        <th class="intraContent"><b>Action</b></th>
        <th class="intraContent"><b>Collection Name</b></th>
        <th class="intraContent"><b>Current Version</b></th>
        <th class="intraContent"><b>Description</b></th>
        <th class="intraContent"><b>Lifecycle </b></th>
        <th class="intraContent"><b>Environment</b></th>
        <th class="intraContent"><b>Released On</b></th>
        <th class="intraContent"><b>Published On </b></th>
        <th class="intraContent"><b>Packages</b></th>
        <th class="intraContent"><b>Queries</b></th>
        <th class="intraContent"><b>Hosts</b></th>
        </tr>
       
        </headertemplate>
        <ItemTemplate>
         <asp:repeater ID="InnerRepeater" runat="Server">
        <ItemTemplate>
        <tr>
        <td class="intraContent">
        <%#DataBinder.Eval(Container.DataItem, "COLLECTION_ID")%>
        </td>
         </ItemTemplate>
        </asp:repeater>
        <td class="intraContent" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><%#DataBinder.Eval(Container.DataItem, "COLLECTION_NAME")%></td>
       
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><%#DataBinder.Eval(Container.DataItem, "Current_Version")%></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><%#DataBinder.Eval(Container.DataItem, "DESCRIPTION")%></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><%#DataBinder.Eval(Container.DataItem, "LIFECYCLE")%></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><%#DataBinder.Eval(Container.DataItem, "ENVIRONMENT")%></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><% Response.Write("????")%></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><%#DataBinder.Eval(Container.DataItem, "PUBLISHED_ON")%></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><asp:linkbutton runat="server" ID="linkButtonc1" CssClass="lnkbutton" CommandName="PACKAGES_COUNT" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"COLLECTION_ID") %>'><%#DataBinder.Eval(Container.DataItem, "PACKAGES")%></asp:linkbutton></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><asp:linkbutton runat="server" ID="linkButtonc2" CssClass="lnkbutton" CommandName="QUERIES_COUNT" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"COLLECTION_ID") %>'><%#DataBinder.Eval(Container.DataItem, "QUERIES")%></asp:linkbutton></td>
        <td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.className='intraContentHover'" onmouseout="this.className='intraContent'"><asp:linkbutton runat="server" ID="linkButtonc3" CssClass="lnkbutton" CommandName="HOSTS_COUNT" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"COLLECTION_ID") %>'><%#DataBinder.Eval(Container.DataItem, "HOSTS") %></asp:linkbutton></td>
        </tr>
        </ItemTemplate>
        <FooterTemplate>
       
        </table>
        </FooterTemplate>
        </asp:Repeater>

When I specify a datasource for the inner Repeater I get errors.

Anyway, what I get with the above code is data for the outer Repeater, but no data for the inner Repeater.

Any ideas?? PLease help!
Thank you!
0
Comment
Question by:rss2
  • 5
  • 2
8 Comments
 
LVL 22

Expert Comment

by:DarkoLord
ID: 18844168
Well, you need to specify a datasource for the inner repeater as there is nothing for it to display without a datasource. What error do you get?
0
 
LVL 12

Expert Comment

by:craskin
ID: 18844369
generally, when i nest repeaters i use a separate function that returns the data i want for the nested repeater. so i'd have something like

Sub Repeater1Load()
    get the data
    bind to repeater1
End Sub

Function NestedData(var1, var2) As DataTable
    return the data with those variables
End Function

<asp:Repeater id="repeater1" ...>
    <itemtemplate>

              <asp:Repeater id="repeater2" datasource='<%# NestedData(Container.DataItem("item1"), Container.DataItem("item2")) %>'>
0
 

Author Comment

by:rss2
ID: 18844889
If done your way, where do you make the relation between the two tables?
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 12

Accepted Solution

by:
craskin earned 500 total points
ID: 18845676
doing what i do, the relation is done by filtering to only those records that apply to the variables sent to the function. say i had a table of people with ID and Name and a table of children with PersonID and ChildName. if you wanted to do a nested repeater with this data (though there is of course a better way to display this kind of data), you'd first bind the person table to the first repeater. then create a function that pulls only the children where PersonID = the ID of the outer repeater's current datarow. so it'd be something like

Function Children(ByVal ID as Integer) As DataTable
      select all children from table here or select only children where PersonID = ID
      if selected all then remove from datatable where PersonID <> ID
      return datatable
End Function

then the nested repeater datasource would = '<%# Children(Container.DataItem("ID")) %>'
0
 

Author Comment

by:rss2
ID: 18850732
When I do it this way, and I reference the dropdownlist within function Children, I get a blue squiggly line underneath it with the error "Name 'ActionDropDownList' is not declared.'

(I gave the dropdownlist the id ActionDropDownList)

why can't I see <asp:Dropdownlist> from wtihin the repeater? If I take it outside the context of the repeater I can see it in my code but not when it's within it.
0
 

Author Comment

by:rss2
ID: 18859109
OMG this has been such a pain to get working.

Finally it's compiling but such an incredible amount of pain I've gone through to get this working.

Okay I think I'm coming down the home stretch now..this question should be easy for you. I'm just so exhausted I can't think straight.

Here's a fragment from my aspx page:
<td class="intraContent">
<asp:DropDownList ID="ActionDropDownList" runat="Server" AutoPostBack="true" OnDataBinding="DropDownListSelect">
</asp:DropDownList>
<asp:Label ID="lblStatus" runat="Server"></asp:Label>
<asp:Repeater ID="InnerRepeater" runat="Server">
<ItemTemplate>


</ItemTemplate>
</asp:Repeater>

and in the code behind file, I have DropDownListSelect which is called when the dropdownlist is bound to data.
    Protected Sub DropdownListSelect(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim conn As New SqlConnection
        Dim cmd As New SqlCommand
        Dim connstring As String
        Dim da As New SqlDataAdapter
        Dim dt As New DataTable
        Dim ds As New Data.DataSet

        'Dim theDropDownList As New DropDownList
        'theDropDownList = CType(FindControl("ActionDropDownList"), DropDownList)

        Dim childa As New SqlDataAdapter
        connstring = Connector.ConnectStringBuild
        conn.ConnectionString = connstring
        cmd.Connection = conn
        cmd.CommandText = "ACT_GET_FUNCTION_SERVICE_DETAILS"
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.Add("@GROUP_NAME", SqlDbType.VarChar).Value = SetVars.GroupName
        cmd.Parameters.Add("@SERVICE_ID", SqlDbType.Int).Value = SetVars.Service_ID
        cmd.Parameters.Add("@OBJECT_NAME", SqlDbType.VarChar).Value = "COLLECTION"

        conn.Open()
        childa.SelectCommand = cmd
        'childa.Fill(dt)
        childa.Fill(ds)
        Dim theDropDownList As New DropDownList

        'theDropDownList = CType(e.Item.FindControl("ActionDropDownList"), DropDownList)
        theDropDownList.DataSource = ds
        theDropDownList.DataBind()


    End Sub

When I run the page, nothing is in the drop down list. What the heck am I doing wrong?

Thanks,
rss2
0
 

Author Comment

by:rss2
ID: 18859164
What do I need to do to actually get the data from the dataset ds inside the dropdownlist?

This is killing me I just can't figure it out!
0
 

Author Comment

by:rss2
ID: 18883659
Is anybody out there??

For the parent repeater, I have
Protected Sub ParentRepeater_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
        Dim ddl As New DropDownList
        ddl = CType(e.Item.FindControl("DropDownListinside"), DropDownList)
        ddl.DataSource = ds
        ddl.DataBind()

..but on the line that says:
CType(e.Item.FindControl("DropDownListinside"),DropDownList)

the ddl object that I instantiate goes to "Nothing" after that line.

So I'm assuming it's not finding the correct control.

How do I get it to find the correct control??? This is maddening.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery + C#.net radiobuttonlist 3 30
VS 2017 18 42
how to just get time from a date 6 33
Phone Does Not Abide By CSS Breakpoint For Navigation Controls 6 21
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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