System.Web.UI.WebControls.Repeater and multiple templates

R

Robert

Hi,
if I create a class A with some properies, then create classes B and C
derived from A, later create and ArrayList filled with some B and C items.
This list I would like to use as a datasource for a repeater control. Is it
possible to add more than one <ItemTemplate>? I would like to have i.e two
templates, one for B and second for C object.
I'm using ASP.NET (2.0) very shortly, but I haven't discovered much about
Repeater/Datalist/Datagrid.
Thank you very much.
Robert
 
P

Phillip Williams

Every Templated databound controls (e.g. datagrid, datalist, repeater) takes
one datasource only. To attach several itemtemplates with several
datasources, you will need to nest databound controls and customize the
codebehind to databind each template (which contain a different user control)
to a different datasource.

I have an example of a datagrid that uses another user control (which is a
child datagrid) within the ItemTemplate to display hierarchical information
(Company table related to the employees table)
1) This sample http://www.societopia.net/Samples/DataGrid_Hierarchy.aspx is
done in declarative mode to make it easy to preserve the event handling.
2) This one http://www.societopia.net/samples/webform2.aspx is done by
dynamically building the datagrid because I do not assume that the levels of
hierarchy are known at design time
 

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

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,107
Latest member
Vinay Kumar Nevatia_
Top