Composite control delegating databound templated features to child <asp:repeater> control

Discussion in 'ASP .Net Building Controls' started by debartsa, Apr 8, 2004.

  1. debartsa

    debartsa Guest

    Hi Everybody,

    I'm creating a composite control in C# that basically renders a bunch of
    webcontrols such as <asp:Label />, <asp:Repeater />, etc... as its children.

    My goal is to re-use the functionality of the <asp:Repeater /> control to
    allow the page developer to take advantage of the Data-bound, Templated
    features the <asp:Repeater /> offers. (I'd like to avoid building that
    functionality from scratch in my control).

    The question is:

    When the page developer using VS.NET drags my control onto an .aspx page,
    I'd like the developer to be able to add his/her own template code
    <ItemTemplate>, etc... and have the processing of the inline template code
    and data-binding expressions delegate down to my child <asp:Repeater> for
    rendering.

    e.g.

    <my:CompositeCtrl id="Cntrl1" runat="server">

    //... The <asp:Repeater> child in my control would handle this block
    ....
    <HeaderTemplate>Title</HeaderTemplate>
    <ItemTemplate>
    <li><a href="<%# DataBinder.Eval(Container.DataItem,
    "URL") %>">
    <%# DataBinder.Eval(Container.DataItem, "Name")
    %></a></li>
    </ItemTemplate>
    <FooterTemplate>Footer Text</FooterTemplate>
    etc...

    </my:CompositeCtrl>


    Is this possible?

    Thanks for any help!
    Sam
    debartsa, Apr 8, 2004
    #1
    1. Advertising

  2. "debartsa" <> wrote in message
    news:...
    > Hi Everybody,
    >
    > I'm creating a composite control in C# that basically renders a bunch of
    > webcontrols such as <asp:Label />, <asp:Repeater />, etc... as its

    children.
    >
    > My goal is to re-use the functionality of the <asp:Repeater /> control to
    > allow the page developer to take advantage of the Data-bound, Templated
    > features the <asp:Repeater /> offers. (I'd like to avoid building that
    > functionality from scratch in my control).
    >
    > The question is:
    >
    > When the page developer using VS.NET drags my control onto an .aspx page,
    > I'd like the developer to be able to add his/her own template code
    > <ItemTemplate>, etc... and have the processing of the inline template code
    > and data-binding expressions delegate down to my child <asp:Repeater> for
    > rendering.
    >
    > e.g.
    >
    > <my:CompositeCtrl id="Cntrl1" runat="server">
    >
    > //... The <asp:Repeater> child in my control would handle this

    block
    > ...
    > <HeaderTemplate>Title</HeaderTemplate>
    > <ItemTemplate>
    > <li><a href="<%# DataBinder.Eval(Container.DataItem,
    > "URL") %>">
    > <%# DataBinder.Eval(Container.DataItem, "Name")
    > %></a></li>
    > </ItemTemplate>
    > <FooterTemplate>Footer Text</FooterTemplate>
    > etc...
    >
    > </my:CompositeCtrl>


    You could delegate the template properties by creating corresponding
    properties in your own code:

    public ITemplate ItemTemplate
    {
    get {EnsureChildControls(); return myChildRepeater.ItemTemplate;}
    set {EnsureChildControls(); myChildRepeater.ItemTemplate = value;}
    }

    However, this won't give you any of the designer features of the Repeater
    control.
    --
    John Saunders
    John.Saunders at SurfControl.com
    John Saunders, Apr 9, 2004
    #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. Replies:
    0
    Views:
    2,212
  2. Rasmus Johansen
    Replies:
    3
    Views:
    379
    VirGin
    Oct 18, 2007
  3. rodchar
    Replies:
    0
    Views:
    379
    rodchar
    Nov 26, 2007
  4. MattC

    Custom Templated Databound Control or derived control?

    MattC, Nov 23, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    176
    MattC
    Nov 23, 2005
  5. Manu
    Replies:
    0
    Views:
    159
Loading...

Share This Page