Hi there. You should be able to accomplish what you want by declaring within your main Repeater's ItemTemplate the nested control (probably another Repeater in your case). Then code an event handler for the main Repeater's ItemDataBound[^] event. Here's an example using an ArrayList for the main data source; each object in the main ArrayList has its own ArrayList of nested objects used for the nested data source.
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load(object o, EventArgs e)
{
if (!IsPostBack) BindMainData();
}
ArrayList GetMainDataSource()
{
// return an arraylist of objects to represent the main datasource
ArrayList arr = new ArrayList();
MainObject m;
m = new MainObject("First Main Object");
m.NestedObjects.Add(new NestedObject("main 1, first nested object") );
m.NestedObjects.Add(new NestedObject("main 1, second nested object") );
m.NestedObjects.Add(new NestedObject("main 1, third nested object") );
arr.Add(m);
m = new MainObject("Second Main Object");
m.NestedObjects.Add(new NestedObject("main 2, first nested object") );
m.NestedObjects.Add(new NestedObject("main 2, second nested object") );
m.NestedObjects.Add(new NestedObject("main 2, third nested object") );
arr.Add(m);
m = new MainObject("Third Main Object");
m.NestedObjects.Add(new NestedObject("main 3, first nested object") );
m.NestedObjects.Add(new NestedObject("main 3, second nested object") );
m.NestedObjects.Add(new NestedObject("main 3, third nested object") );
arr.Add(m);
return arr;
}
void BindMainData()
{
// bind the main datasource
rptMain.DataSource = GetMainDataSource();
rptMain.DataBind();
}
void rptMain_ItemDataBound(object o, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
// if this is a normal item type, then locate the nested repeater
Repeater rpt = e.Item.FindControl("rptNested") as Repeater;
i