Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

DataPager

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 10 Mar 2008 19:24 GMT
Hello,

I am creating a DataPager TemplatePagerField at runtime and trying to
replicate the following paging:

http://www.frequency-decoder.com/demo/table-sort-revisited/paginate/

At the moment this is not working very well. A postback is made every
time I click a button or a number.

I think it is my calculation on my TemplatePagerField PagerCommand
event.

Could someone help me out?

Thank You,

Miguel

Here is my code:

PagerCommand event handler

   Private Sub tpftags_PagerCommand(ByVal sender As Object, ByVal e
As DataPagerCommandEventArgs)

     ' Check which button raised the event
     Select Case e.CommandName

       Case "Next"
         Dim newIndex As Integer = e.Item.Pager.StartRowIndex +
e.Item.Pager.PageSize
         If newIndex <= e.TotalRowCount Then
           e.NewStartRowIndex = newIndex
           e.NewMaximumRows = e.Item.Pager.MaximumRows
         End If

       Case "Previous"
         Dim newIndex As Integer = e.Item.Pager.StartRowIndex +
e.Item.Pager.PageSize
         If newIndex >= e.TotalRowCount Then
           e.NewStartRowIndex = e.Item.Pager.StartRowIndex -
e.Item.Pager.PageSize
           e.NewMaximumRows = e.Item.Pager.MaximumRows
         End If

       Case "First"
         e.NewStartRowIndex = 0
         e.NewMaximumRows = e.Item.Pager.MaximumRows

       Case "Last"
         e.NewStartRowIndex = e.Item.Pager.MaximumRows -
e.Item.Pager.PageSize
         e.NewMaximumRows = e.Item.Pager.MaximumRows

       Case "Number"
         e.NewStartRowIndex = Convert.ToInt32(e.CommandArgument)
         e.NewMaximumRows = e.Item.Pager.MaximumRows

     End Select

   End Sub

Class that implements ITemplate:

 Public Class PagerTemplate
   Implements ITemplate

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

     Dim lbfirst As New LinkButton
     lbfirst.Text = "«"
     lbfirst.CommandName = "First"
     container.controls.add(lbfirst)

     Dim lbprevious As New LinkButton
     lbprevious.Text = "<"
     lbprevious.CommandName = "Previous"
     container.controls.add(lbprevious)

     Dim cont As DataPagerFieldItem = CType(container,
DataPagerFieldItem)
     Dim a As DataPager = CType(cont.NamingContainer, DataPager)

     Dim currentPage As Integer = (a.StartRowIndex / a.PageSize) + 1
     Dim totalPages As Integer = a.TotalRowCount / a.PageSize

     For i = currentPage To totalPages

       Dim lbnumber As New LinkButton
       lbnumber.Text = i.ToString
       lbnumber.CommandArgument = i.ToString
       lbnumber.CommandName = "Number"
       container.controls.Add(lnnumber)

     Next i

     Dim lbnext As New LinkButton
     lbnext.Text = ">"
     lbnext.CommandName = "Next"
     container.Controls.Add(lbnext)

     Dim lblast As New LinkButton
     lblast.Text = "»"
     lblast.CommandName = "Last"
     container.Controls.Add(lblast)

   End Sub ' InstantiateIn

#End Region ' Implementation

#Region "Controls Events"

#End Region ' Controls Events

 End Class ' PagerTemplate
shapper - 13 Mar 2008 14:52 GMT
> Hello,
>
[quoted text clipped - 113 lines]
>
>   End Class ' PagerTemplate

Please, anyone?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.