Solved

Inner Repeater not displaying data

Posted on 2007-04-03
8
560 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
Comment Utility
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
Comment Utility
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
Comment Utility
If done your way, where do you make the relation between the two tables?
0
 
LVL 12

Accepted Solution

by:
craskin earned 500 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:rss2
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now