This topic has not yet been rated - Rate this topic

RenderingTemplateContainer Class

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RenderingTemplateContainer : Control, 
	IDataItemContainer, INamingContainer
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
RenderingTemplateContainer
Description

The Microsoft.SharePoint.WebControls.RenderingTemplateContainer class inherits from the System.Web.UI.IDataItemContainer interface for data item object identification as well as the System.Web.UI.Control class in order to define an ASP.NET server control. The RenderingTemplateContainer represents an individual container data item within a RenderingTemplate. 

RenderingTemplateContainer works through the use of three properties.

RenderingTemplateContainer.DataItem – Represents an individual data item bound with the RenderingTemplate

RenderingTemplateContainer.DataItemIndex – Represents the index of the data item 

RenderingTemplateContainer. DisplayIndex – Represents the position of the item as displayed with the RenderingTemplate

The Usage Scenario

The primary use of RenderingTemplateContainer is internal, having representation in SPCalendar* classes. However, it is possible to use RenderingTemplateContainer as a base class within custom development.

In the below, the MyContainer class is inheriting from the RenderingTemplateContainer class. I am declaring a global object type variable which represents the data item.

C# Code Example

public class MyContainer : RenderingTemplateContainer
{
private readonly object obj;
public MyContainer(object obj)
{
this.obj = obj;
}
public object DataItem
{
get
{
return obj;
}
}


Visual Basic .NET Code Example

Public Class MyContainer
Inherits RenderingTemplateContainer
Private ReadOnly obj As Object

Public Sub New(ByVal obj As Object)
Me.obj = obj
End Sub

Public ReadOnly Property DataItem() As Object
Get
Return obj
End Get
End Property
End Class

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com