PDA

Click to See Complete Forum and Search --> : TemplateControl & ITemplate


Magiaus
Oct 10th, 2003, 03:34 PM
I am making a Pagable Repeater Control becaus I just don't like the excel/access datagrid layout and I want to be able to page a custom view.

Here is what I have.
Imports System.ComponentModel
Imports System.Data
Imports System.Web
Imports System.Web.UI

<ParseChildren(True), _
ToolboxData("<{0}:CustomPager runat=server></{0}:CustomPager>")> _
Public Class CustomPager : Inherits TemplateControl
Private Class RepeaterItem : Inherits Control : Implements INamingContainer
Private _ItemIndex As Integer
Private _DataItem As Object

Public Sub New(ByVal ItemIndex As Integer, ByVal DataItem As Object)
MyBase.New()
_ItemIndex = ItemIndex
_DataItem = DataItem
End Sub
Public ReadOnly Property DataItem() As Object
Get
Return _DataItem
End Get
End Property
Public ReadOnly Property ItemIndex() As Integer
Get
Return _ItemIndex
End Get
End Property
End Class

Private _AlternatingItemTemplate As ITemplate = Nothing
<TemplateContainer(GetType(RepeaterItem))> Public Property AlternatingItemTemplate() As ITemplate
Get
Return _AlternatingItemTemplate
End Get
Set(ByVal Value As ITemplate)
_AlternatingItemTemplate = Value
End Set
End Property
Private _ItemTemplate As ITemplate = Nothing
<TemplateContainer(GetType(RepeaterItem))> Public Property ItemTemplate() As ITemplate
Get
Return _ItemTemplate
End Get
Set(ByVal Value As ITemplate)
_ItemTemplate = Value
End Set
End Property
Private _FooterTemplate As ITemplate = Nothing
<TemplateContainer(GetType(RepeaterItem))> Public Property FooterTemplate() As ITemplate
Get
Return _FooterTemplate
End Get
Set(ByVal Value As ITemplate)
_FooterTemplate = Value
End Set
End Property
Private _HeaderTemplate As ITemplate = Nothing
<TemplateContainer(GetType(RepeaterItem))> Public Property HeaderTemplate() As ITemplate
Get
Return _HeaderTemplate
End Get
Set(ByVal Value As ITemplate)
_HeaderTemplate = Value
End Set
End Property
Private _DataSource As WebControls.BaseDataList = Nothing
Public Property DataSource() As WebControls.BaseDataList
Get
Return _DataSource
End Get
Set(ByVal Value As WebControls.BaseDataList)
_DataSource = Value
End Set
End Property


Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)
End Sub
Protected Overrides Sub CreateChildControls()

End Sub
Protected Overrides Sub OnDataBinding(ByVal e As System.EventArgs)

End Sub

End Class

What I am Curious about is when you use an <asp:Repeater> you get intell sense on <ItemTemplate> and so on and vs.net doesn't whine about tags being undefined. My class does not work like that and vs.net does whine. Does that mean my control won't work like a repeater?

I am just curious because I want to fix it know before I write all the loopy logic and data handling to draw out the templates. Is there one already because this is going to be allot of code for something that is already there.

Thanks for any insight, ideas and oh I wrote one alreadys.

Magiaus
Oct 12th, 2003, 04:21 PM
Nobody has ever made a template control?

Lord_Rat
Oct 14th, 2003, 02:40 PM
unfortunately, no.

Magiaus
Oct 14th, 2003, 02:44 PM
I think you mean fortunatly.... it's slightly confusing. I mean if it was documented maybe it wouldn't be, but hey who needs more then one printed page or two of documetation anyway.