Extending DataPager

S

shapper

Hello,

I am trying to extend DataPager control to have predefined template
fields.

Public Class WebPager
Inherits DataPager

Protected Overloads Overrides Sub OnInit(ByVal e As
EventArgs)
MyBase.OnInit(e)
Dim field As New TemplatePagerField
field.PagerTemplate = New WebPagerTemplate()
Me.Fields.Add(field)
Me.Fields.Add(field)
End Sub

End Class

And the template field is defined as follows:

Public Class WebPagerTemplate
Implements ITemplate

Public Sub InstantiateIn(ByVal container As Control) Implements
ITemplate.InstantiateIn
...
End Sub

End Class

The problem is that I need to run some code inside the
TemplatePagerField's Command event.

So I need to override it right?

How can I do this?

And should I do it in class WebPager or in WebPagerTemplate.

In my opinion I should override the OnCommand event in
WebPagerTemplate but I don't know how to do it.

Could someone, please, help me out?

Thanks,

Miguel
 
S

shapper

Hello,

I am trying to extend DataPager control to have predefined template
fields.

Public Class WebPager
Inherits DataPager

Protected Overloads Overrides Sub OnInit(ByVal e As
EventArgs)
MyBase.OnInit(e)
Dim field As New TemplatePagerField
field.PagerTemplate = New WebPagerTemplate()
Me.Fields.Add(field)
Me.Fields.Add(field)
End Sub

End Class

And the template field is defined as follows:

Public Class WebPagerTemplate
Implements ITemplate

Public Sub InstantiateIn(ByVal container As Control) Implements
ITemplate.InstantiateIn
...
End Sub

End Class

The problem is that I need to run some code inside the
TemplatePagerField's Command event.

So I need to override it right?

How can I do this?

And should I do it in class WebPager or in WebPagerTemplate.

In my opinion I should override the OnCommand event in
WebPagerTemplate but I don't know how to do it.

Could someone, please, help me out?

Thanks,

Miguel

Hello,

I found the following:

"The OnPagerCommand method also enables derived classes to handle the
event without attaching a delegate. This is the preferred technique
for handling the event in a derived class.

Notes to Inheritors:
When you override OnPagerCommand in a derived class, call the base
class's OnPagerCommand method so that registered delegates receive the
event."

In this article:
http://msdn2.microsoft.com/en-us/li...ntrols.templatepagerfield.onpagercommand.aspx

However, I am not sure how to do this.

Could someone, please, help me out?

I don't know to to start.

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top