Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Custom template in Repeater

Reply
Thread Tools

Custom template in Repeater

 
 
dotNet
Guest
Posts: n/a
 
      02-08-2005
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!
 
Reply With Quote
 
 
 
 
IgorW
Guest
Posts: n/a
 
      02-08-2005
Look:
http://msdn.microsoft.com/asp.net/ar...edcontrols.asp



On Tue, 08 Feb 2005 16:52:27 +0100, dotNet <(E-Mail Removed)> 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!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template template arguments: expected a class template, got `Component<T1, T2, T3> gary.bernstein@gmail.com C++ 1 06-08-2007 07:10 AM
Custom control within repeater with custom object binding - .net 1 =?Utf-8?B?SmF5YnVmZmV0?= ASP .Net 9 02-21-2006 03:38 AM
Adding custom template to repeater HmFireBall ASP .Net Building Controls 2 01-12-2006 09:53 PM
Re: A Newbie Question about template template template tom_usenet C++ 0 07-24-2003 12:06 PM
Re: A Newbie Question about template template template Chris Theis C++ 2 07-24-2003 09:42 AM



Advertisments