nested databound controls

P

Phil Townsend

I want to add a datalist to a Repeater control. The data for the
datalist resides in a cached DataSet that contains two related tables.
The data in last child table should be rendered in three columns, so I
have decided on a DataList control for this purpose. A repeater will
render values from the parent table. I am attempting to call the
ItemDataBound event of the Repeater control to build a DataList and
render it to the page. I have written code to perform this and it runs
without errors, however, nothing gets rendered to the page. I am fairly
new to building a dynamic contorl like this one. I am doing somehting
wrong obviously, but what? I don't know. Any suggestions? Code excerpt
follows (I would like dlusers to render to the datalist control)...

foreach(DataRow drsub in
((DataSet)Cache["fullhierarchy"]).Tables[0].Rows)
{
dlusers=new DataList();
DataTable dtusers=new DataTable();
DataColumn dcln=new DataColumn("LastName");
DataColumn dcfn=new DataColumn("FirstName");
dtusers.Columns.Add(dcln);
dtusers.Columns.Add(dcfn);
foreach(DataRow druser in drsub.GetChildRows("subcomm_users"))
{
// build a dynamic datalist here
DataRow dr=dtusers.NewRow();
dr["LastName"]=druser["lname"].ToString();
dr["FirstName"]=druser["fname"].ToString();
dtusers.Rows.Add(dr);
}
dlusers.DataSource=dtusers;
dlusers.DataBind();
}
 
S

Scott Allen

Phil,

The way I would approach this would be to put the DataList markup tag
inside of the Reapeter markup, sort of like:

<asp:Repeater ...>
...
< asp:DataList ... />
...
</asp:Repeater>

Soemthing very similar would be putting a DropDownList inside of a
DataGrid (one data bound control inside of another) :
http://odetocode.com/Articles/231.aspx

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top