Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / October 2006

Tip: Looking for answers? Try searching our database.

Can a repeater's ItemTemplate instantiate derived classes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Big Daddy - 27 Oct 2006 16:47 GMT
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
John Saunders - 28 Oct 2006 11:39 GMT
>I posted this in a different group yesterday with no responses, so I'll
> try here.
[quoted text clipped - 18 lines]
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.