Ask a Question related to ASP.NET Building Controls, Design and Development.
-
debartsa #1
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
-
Problems with Templated Databound control
Hi! In my templated databound control (inherited from CompositeDataBoundControl) I have one template and one string get/set property. When... -
Custom Templated Databound Control or derived control?
Hi, I want to create a control that performs much like a datalist but I want more control over how the <ItemTemplate> contents is set out on the... -
Composite Control - Event not firing in child control
Hello: I am experiencing an issue where I have a composite control (TestOuter) composed of more composite (TestInner) controls. When I am... -
Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have... -
DataList parrent control with a Repeater child control
I've been trying to bind a Repeater 'child control' to a DataList control and seem to have lost the plot. Tec spec: Connection to SQL server 2... -
John Saunders #2
Re: Composite control delegating databound templated features to child <asp:repeater> control
"debartsa" <debartsa@btib.css.gov.on.ca> wrote in message
news:uD9V0laHEHA.2300@tk2msftngp13.phx.gbl...children.> 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 itsblock>
> 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 thisYou could delegate the template properties by creating corresponding> ...
> <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>
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



Reply With Quote

