Custom template in Repeater

Discussion in 'ASP .Net Building Controls' started by dotNet, Feb 8, 2005.

  1. dotNet

    dotNet Guest

    Hello!

    I want to add another template to the templates that are already
    available with the repeater control.

    This is what I have done so far...

    Created a class that inherits from WebControl and implements
    INamingContainer to hold my controls that I add in my template.

    public class PagedRepeaterTemplateItem : WebControl, INamingContainer
    {
    }


    Inherit the repeater to my custom repeater..

    public class PagedRepeater : Repeater
    {
    //Added an ITemplate property..

    private ITemplate pagingTemplate = null;
    public ITemplate PagingTemplate
    {
    get { return pagingTemplate; }
    set { pagingTemplate = value; }
    }

    //Override the current CreateChildControls()
    protected override void CreateChildControls()
    {
    this.Controls.Clear();

    PagedRepeaterTemplateItem item = new PagedRepeaterTemplateItem();

    PagingTemplate.InstantiateIn(item);
    this.Controls.Add(item);

    }
    }

    I have also tried to override the Render()-method, but when I check the
    this.Controls()-collection when I am in that method I notice that the
    controls that I add in the CreateChildControls() are gone.

    Anyone know what I have missed, and how I can make it to work?

    Thanks!
    dotNet, Feb 8, 2005
    #1
    1. Advertising

  2. dotNet

    IgorW Guest

    Look:
    http://msdn.microsoft.com/asp.net/a...us/dnaspp/html/databoundtemplatedcontrols.asp



    On Tue, 08 Feb 2005 16:52:27 +0100, dotNet <> wrote:

    > Hello!
    >
    > I want to add another template to the templates that are already
    > available with the repeater control.
    >
    > This is what I have done so far...
    >
    > Created a class that inherits from WebControl and implements
    > INamingContainer to hold my controls that I add in my template.
    >
    > public class PagedRepeaterTemplateItem : WebControl, INamingContainer
    > {
    > }
    >
    >
    > Inherit the repeater to my custom repeater..
    >
    > public class PagedRepeater : Repeater
    > {
    > //Added an ITemplate property..
    >
    > private ITemplate pagingTemplate = null;
    > public ITemplate PagingTemplate
    > {
    > get { return pagingTemplate; }
    > set { pagingTemplate = value; }
    > }
    >
    > //Override the current CreateChildControls()
    > protected override void CreateChildControls()
    > {
    > this.Controls.Clear();
    >
    > PagedRepeaterTemplateItem item = new PagedRepeaterTemplateItem();
    >
    > PagingTemplate.InstantiateIn(item);
    > this.Controls.Add(item);
    >
    > }
    > }
    >
    > I have also tried to override the Render()-method, but when I check the
    > this.Controls()-collection when I am in that method I notice that the
    > controls that I add in the CreateChildControls() are gone.
    >
    > Anyone know what I have missed, and how I can make it to work?
    >
    > Thanks!
    IgorW, Feb 8, 2005
    #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. =?Utf-8?B?SmF5YnVmZmV0?=
    Replies:
    9
    Views:
    840
    Phillip Williams
    Feb 21, 2006
  2. Chris Theis
    Replies:
    2
    Views:
    460
    Chris Theis
    Jul 24, 2003
  3. tom_usenet
    Replies:
    0
    Views:
    527
    tom_usenet
    Jul 24, 2003
  4. Replies:
    1
    Views:
    2,088
    Gianni Mariani
    Jun 8, 2007
  5. HmFireBall

    Adding custom template to repeater

    HmFireBall, Jan 5, 2006, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    158
    HmFireBall
    Jan 12, 2006
Loading...

Share This Page