469,898 Members | 1,815 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

nested databound controls

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();
}

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
1 3502
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,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 10 Dec 2004 19:44:25 -0800, Phil Townsend
<ph*******@yahoo.com> wrote:
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();
}

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Yasir Hussain | last post: by
reply views Thread by hammad.awan_nospam | last post: by
6 posts views Thread by Steve Hershoff | last post: by
3 posts views Thread by Jeff | last post: by
4 posts views Thread by =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post: by
6 posts views Thread by =?Utf-8?B?SnVzdGlu?= | last post: by
2 posts views Thread by Josh | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.