Link to home
Start Free TrialLog in
Avatar of rss2
rss2

asked on

Inner Repeater not displaying data

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!
Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

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?
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")) %>'>
Avatar of rss2
rss2

ASKER

If done your way, where do you make the relation between the two tables?
ASKER CERTIFIED SOLUTION
Avatar of craskin
craskin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rss2

ASKER

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.
Avatar of rss2

ASKER

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
Avatar of rss2

ASKER

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!
Avatar of rss2

ASKER

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.