Can a repeater's ItemTemplate instantiate derived classes?

B

Big Daddy

I posted this in a different group yesterday with no responses, so I'll
try here.

I would like to have a repeater class like this:

<asp:Repeater ID="CriteriaRepeater" runat="server" >
<ItemTemplate>
<uc1:BaseControl ID="BaseControl1" BindData='<%#
Container.DataItem %>' runat="server" />
</ItemTemplate>
</asp:Repeater>

The thing that is getting repeated for each item in the datasource is a

user control that is a base class. I would like it to actually create
different controls that are devired from the base control, depending on

the values in the datasource. For example, if there are three classes
derived from BaseControl1 (DerivedControl1, DerivedControl2,
DerivedControl3), if the datasource has three records, the repeater
would be able to create one instance of each of the derived classes
rather than three instances of the base class. Is this possible?

Thanks in advance,
John
 
J

John Saunders

Big Daddy said:
I posted this in a different group yesterday with no responses, so I'll
try here.

I would like to have a repeater class like this:

<asp:Repeater ID="CriteriaRepeater" runat="server" >
<ItemTemplate>
<uc1:BaseControl ID="BaseControl1" BindData='<%#
Container.DataItem %>' runat="server" />
</ItemTemplate>
</asp:Repeater>

The thing that is getting repeated for each item in the datasource is a

user control that is a base class. I would like it to actually create
different controls that are devired from the base control, depending on

the values in the datasource. For example, if there are three classes
derived from BaseControl1 (DerivedControl1, DerivedControl2,
DerivedControl3), if the datasource has three records, the repeater
would be able to create one instance of each of the derived classes
rather than three instances of the base class. Is this possible?

It's possible if you write it. ;-)

You would need to create a composite control which decided on its child
control(s) based on the data source. Put it inside of the repeater, data
bind it, and you're all set.

John
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top