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