I'm having some dramas with Nested Repeaters in ASP.NET using VB.
I have search through this and a few other forums but cannot work out my code problem. All of the other examples ive found have been using an XML Datasource, or using multiple tables within a dataset. My Dataset only contains 1 table with all the necessary fields.
I essentially want to create an Event Calendar... eg
-September
Event 1
Event 2
-October
Event 3
-November
Event 4
Event 5
Event 6
All of the info is stored in 1 Table in my Database.
My Code so Far...
aspx
<asp:repeater id="rptCalendar" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "Month")%>
<asp:repeater id="NestedRepeater" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "EventName")%>
<br>
</ItemTemplate>
</asp:repeater>
</ItemTemplate>
</asp:repeater>
aspx.vb
Protected Sub rptCalendar_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptCalendar.ItemDataBound
Dim dv As DataRowView = e.Item.DataItem
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim nestedrepeater As Repeater = e.Item.FindControl("NestedRepeater")
Dim drv As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
nestedrepeater.DataSource = drv.CreateChildView("EventName")
nestedrepeater.DataBind()
End If
End Sub
My Page_Load event just loads the entire table into a dataset called dsEvents and binds it. The Database looks like this.
-Events
EventID
EventName
EventDate
Month
Day
The error message im getting is "The relation is not parented to the table to which this DataView points."
I haven't worked with Nested Repeaters before so not too sure what im doing wrong.