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.
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.