Can a repeater's ItemTemplate instantiate derived classes?

Discussion in 'ASP .Net Building Controls' started by Big Daddy, Oct 27, 2006.

  1. Big Daddy

    Big Daddy Guest

    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
    Big Daddy, Oct 27, 2006
    #1
    1. Advertising

  2. "Big Daddy" <> wrote in message
    news:...
    >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
    John Saunders, Oct 28, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bennett Haselton
    Replies:
    1
    Views:
    5,328
    Joe Fallon
    Sep 24, 2004
  2. Colin Goudie
    Replies:
    6
    Views:
    466
    Victor Bazarov
    Jan 26, 2004
  3. Replies:
    1
    Views:
    393
    myork
    May 23, 2007
  4. Replies:
    1
    Views:
    385
    Victor Bazarov
    May 23, 2007
  5. Big Daddy

    Can a repeater's ItemTemplate instantiate derived classes?

    Big Daddy, Oct 26, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    178
    Phil H
    Oct 29, 2006
Loading...

Share This Page