dragonwell
Programmer
My DataList has an interesting DataSource - it's an ArrayList of objects. Each of the objects in my DataSource ArrayList has some string properties and a property that is a collection (another ArrayList).
On my page, I have my DataList bound to the ArrayList. No problem. Within the ItemTemplate, I have a DataGrid which I want to bind to the collection that is part of the current object.
Here's what the Datalist looks like:
I thought of replacing the ????? with a call to a helper method that returns a collection. Something like:
but I would need to pass in the object I am currently binding to in the master DataList, right? How would I reference it? I've been trying:
but that doesn't work.
Anyway, the GetCollection() method if have so far is this:
Anyone have any idea on how I could accomplish this? Thanks!
On my page, I have my DataList bound to the ArrayList. No problem. Within the ItemTemplate, I have a DataGrid which I want to bind to the collection that is part of the current object.
Here's what the Datalist looks like:
Code:
<asp:DataList runat="server" id="DataList1">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "MyString")%>
<asp:DataGrid runat="server" id="DataGrid1"
datasource="???????????????????????">
</asp:DataGrid>
</ItemTemplate
</asp:DataList>
I thought of replacing the ????? with a call to a helper method that returns a collection. Something like:
Code:
datasource="<%# GetCollection() %>"
but I would need to pass in the object I am currently binding to in the master DataList, right? How would I reference it? I've been trying:
Code:
datasource = "<%# GetCollection(Container.DataItem) %>"
Anyway, the GetCollection() method if have so far is this:
Code:
public ArrayList GetCollection(DataListItem item)
{
DataList list = (DataList)item.Parent;
MyObject detail = (MyObject)list.DataSource;
return detail.MyCollection;
}
Anyone have any idea on how I could accomplish this? Thanks!