Is it possible in asp.net to have a datalist in the itemtemplate of another
datalist?
For example:
<asp:datalist id="MyList" runat="server">
<ItemTemplate>
<table border="0" width="300">
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "title") %></td>
</tr>
<tr>
<td><asp:datalist id="AnotherList" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "something")
%>
</ItemTemplate>
</td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>
Then in the Code behind:
MyList.DataSource = MyDatabase.GetTitles(); // MyDatabase.GetTitles returns
a dataset
MyList.DataBind();
AnotherList.DataSource = MyDatabase.GetSomething();
AnotherList.DataBind();
I keep getting a "System.NullReferenceException: Object reference not set to
an instance of an object" error when it gets to the AnotherList.DataSource
line.
So is it possible to have a Datalist in another Datalist, and if so, what's
the correct way of doing it?