Nested Repeaters in VB.NET

Last post 08-27-2009 12:00 AM by Kuchee. 1 replies.

Sort Posts:

  • Nested Repeaters in VB.NET

    04-23-2007, 6:31 PM
    • Member
      468 point Member
    • DaveC426913
    • Member since 09-21-2005, 6:26 PM
    • Posts 291

    I've given up on my original dynamically-constructed poll page and am going with nested repeaters.


    I'm coming along pretty well, I just can't figure out how to populate the child repeater using a relation. All the really simple examples are in C#.

    This is what I'm going from:

    http://www.aspnettutorials.com/tutorials/controls/nested-repeater-vb.aspx

     

     My code:

            Dim theDB As New db
            Dim query As String
            Dim QueSet As New DataSet
            Dim AnsSet As New DataSet
            Dim Ans As New DataSet

            Dim PollID As Integer = 1

            query = "SELECT * FROM [Questions] WHERE [PollID]=" & PollID
            QueSet = theDB.ExecuteOtherQuery(query)
            rptQuestion.DataSource = QueSet.Tables("Questions")

            query = "SELECT * FROM [MC_Answers] WHERE [PollID]=" & PollID & " AND [Questions.Order]=[MC_Answers.QuestionID]"
            AnsSet = theDB.ExecuteOtherQuery(query)
            AnsSet.Relations.Add("MyRelation", AnsSet.Tables("Questions").Columns("Order"), AnsSet.Tables("MC_Answers").Columns("QuestionID"))

     
            Page.DataBind()
     

    I don't really understand if I've got the above lines correct. 

     

     

    My asp:

             <asp:Repeater runat="server" id="rptQuestion">
                <ItemTemplate>
                    <%#DataBinder.Eval(Container.DataItem, "QText_E")%><br />
                    <asp:Repeater runat="server" id="rptAnswer" datasource='<%# Ctype(Container.Dataitem,RepeaterItem).DataItem.GetChildRows("myrelation")%>'>
                         <ItemTemplate>
                             <%#DataBinder.Eval(Container.DataItem, "AText_E")%>
                         </ItemTemplate>
                    </asp:Repeater>
                </ItemTemplate>
            </asp:Repeater>

    My schema

     

    Questions

    PollID               QText_E          QText_F            Type                 Order

     

    Order and PollID together serve as a primary key for the questions table. Thus, the MC_Answers table  has a many-to-one relationship with the Questions table.
     

    MC_Answers

    PollID               QuestionID         AText_E          AText_F            Order


     

  • Re: Nested Repeaters in VB.NET

    08-27-2009, 12:00 AM
    • Member
      16 point Member
    • Kuchee
    • Member since 08-17-2009, 3:51 AM
    • Posts 10

     Please help me with nested repeaters.

    im unable to find even a single proper working example..

     

Page 1 of 1 (2 items)