Professional Web Applications Themes

Composite control delegating databound templated features to child <asp:repeater> control - ASP.NET Building Controls

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 ...

  1. #1

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

    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 Guest

  2. #2

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

    "debartsa" <debartsabtib.css.gov.on.ca> wrote in message
    news:uD9V0laHEHA.2300tk2msftngp13.phx.gbl...
    > 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 Guest

Similar Threads

  1. Problems with Templated Databound control
    By paululvinius@hotmail.com in forum ASP.NET Building Controls
    Replies: 1
    Last Post: December 1st, 08:15 PM
  2. Custom Templated Databound Control or derived control?
    By MattC in forum ASP.NET Building Controls
    Replies: 1
    Last Post: November 25th, 03:16 PM
  3. Composite Control - Event not firing in child control
    By Chris Simmons in forum ASP.NET Building Controls
    Replies: 3
    Last Post: October 28th, 09:45 PM
  4. Replies: 2
    Last Post: July 22nd, 10:58 PM
  5. DataList parrent control with a Repeater child control
    By SL in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: June 24th, 11:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139