Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   Custom template in Repeater (http://www.velocityreviews.com/forums/t757433-custom-template-in-repeater.html)

dotNet 02-08-2005 03:52 PM

Custom template in Repeater
 
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 02-08-2005 08:09 PM

Re: Custom template in Repeater
 
Look:
http://msdn.microsoft.com/asp.net/ar...edcontrols.asp



On Tue, 08 Feb 2005 16:52:27 +0100, dotNet <dotnet@brimba.nu> 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!




All times are GMT. The time now is 07:27 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.