How to get custom paging like the one in this forum

I need somebody to point me in the right direction to create a usercontrol that has custom paging to apply to my gridviews that looks exactly like the one used for this forum at the bottom:

 Page 1 of 2003 (40059 items) 1 2 3 4 5 Next > ... Last »

I am looking for C# code and is it possible to accomplish this using the objectdatasource object?

Thanks

0
olandera
7/6/2007 3:53:35 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
644 Views

Similar Articles

[PageSpeed] 55

 Well, I had to come up with a custom paging plan since I was using repeaters that don't have paging built in..

Here is an example of how I did that.. Maybe this will lead you in the right direction.

In the aspx, I set in my repeater, and a label called lblPage, and 2 link buttons called btnPrev and btnNext. (the link buttons are set to be invisible)

In the code behind, I created a public property called CurrentPage which sets a viewstate item called CurrentPage

i.e.

Public Property CurrentPage() as Integer
    Get
        Dim o as Object = ViewState.Item("CurrentPage")
        If o Is Nothing Then
            Return 0
        Else
            Retuen o
        End If
    End Get
    Set(ByVal value As Integer)
        ViewState.Item("CurrentPage") = value
    End Set
End Property

Then I create a sub to bind the my data to the repeater (or any other bindable tag)...

Protected Sub BindData(Optional ByVal CurPage As Integer = 0)
    ...{create connection and command and fill your DataAdapter}...
    Dim pds As New PagedDataSource
    pds.DataSource = {whatever you called your dataset}.Tables(0).DefaultView
    pds.AllowPagin = True
    pds.PageSize = 20 (or whatever)

    pds.CurrentPageIndex = CurPage
    CurrentPage = pds.CurrentPageIndex + 1

    If pds.PageCount > 1 Then
        lblPage.Text = "Page : " & CurrentPage & " of " & pds.PageCount
    Else
        lblPage.Text = String.Empty
    End If

    btnPrev.Visible = (Not pds.IsFirstPage)
    btnNext.Visible = (Not pds.IsLastPage)

    {bindable tag}.DataSource = pds
    {bindable tag}.DataBind

End Sub

Then you need to create events for your linkbuttons and rebind the tag passing in CurrentPage.
(i.e. btnNext onClick would run BindData(CurrentPage), and btnPrev would run BindData(CurrentPage - 1) )

Hope this helps...

Let me know if you have any other questions.
 


Andrew S. Erwin
Software Developer
ReflectSystems, Inc.

0
cyberwin
7/6/2007 5:13:49 PM
Reply:

Similar Artilces:

Creating .Net custom server controls and .Net pages programatically
Thanks a lot for reading this and greatly appreciate your inputs I am writing a webinterface that lets users configure options that'll create an interface for them and generete the webpage. So I am having to programattically create custom server controls and .Net page with code behind to support the functionality. Are there APIs in the .NET SDK that let you do this. Any pointers would be greatly helpful Thanks a lot Sathya Controls on the fly? Or Create code on the fly? I think it is the latter so here we go - look at the following namespaces: * System.Reflection.Emit - gen...

Custom composite contorl contains custom contols: controls collection gets empty (Or control get reinitialized) on postback.
Hi, I'm  developing a ASP .Net custom server control library. Where all the basic(Text,check,etc) controls are working well. I have developed an composite control which is more like a Tabular control with the basic custom controls in every cell. The problem is, this composite control reinitializes on post back. I 've added the custom controls (in CreateChildControls method) as cell.controls.add(customcontrol)  row.controls.add(cell) ; this.controls.add(row) Please give me a solution as early as possible IMXO. ASP.NET constructs and reinitializes&n...

How can one call a custom server control DLL like a custom class library DLL
All -- How can one call a custom server control DLL like a custom class library DLL? Please help. I think that I am missing something simple? Or, maybe I am trying to do something impossible? Or, maybe something else? I have a custom server control DLL that I built, with a UI, etc, called... (A). App_Web_teamthemeselectorwebcontrol.ascx.cdcab7d2.dll ...and it works fine. I register my custom server control DLL on an ASPX page like this... (B). <%@ register tagprefix="team" namespace="Team.WebControls" assembly="App_Web_teamthemeselectorwebcontrol.a...

Dot Net Nuke (DNN)
Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-b...

How to getting custom protocol custom-protocol://some-uri-path to act like http to support page browser?
For example. custom-protocol://some-uri-path/test.html I want the test.html works like http://some-web-site/test.html That I can navigate in the html page. On 6/24/15 1:10 PM, Yonggang Luo wrote: > For example. > custom-protocol://some-uri-path/test.html > > I want the test.html works like > > http://some-web-site/test.html > That I can navigate in the html page. > Check out nsIProtocolHandler Here is an implementation that directly forwards to http(s): http://mxr.mozilla.org/comm-central/source/calendar/base/src/calProtocolHandler.js Ph...

How to create custom properties for aspx page which should refelect in design time properties window itself.( as like as custom server control).
Hi. I need to create the custom properties for aspx page itself where those custom properties should refelet in the properties window at the design time as like as other custom server controls. I tried pageBase class which will have cusom properties for page and inherited that pageBase to my aspx page . But its refelecting the code  behind file not in design time. I need to accss those aspx page custom properties at the design time itself in properties window as like as other custom server control.I appriciate your help. [FYI: my scenerio is customer ...

customizing the createuserwizard control in one page
Hi, I have a prob with the  createuserwizard, basically what I want is registration just in one page. But i have a problem to get the user id to insert into another table as foreign key. Below are   the codes1 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) 2 { 3 TextBox tb = (TextBox)CreateUserWizard1.FindControl("UserName"); //here is the prob 4 5 MembershipUser User = Membership.GetUser(tb.Text); // here is the prob 6 object UserGUID = User.ProviderUserKey; // here is the prob 7 ...

Having a problem getting custom controls in a page
I want to extend some existing controls and use them in pages but I keep getting reference problems.  The page can see the controls in design mode but gives me reference error when I try to compile. Please post the code for the page and UC. public class EventCalendar: System.Web.UI.WebControls.Calendar { }      <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %> <%@ Register TagPrefix="...

Custom Control: Calling a function on calling page FROM a custom control ? help !!
I have a custom control placed on many pages, to make things simple, basically what I want to do is Call a function on the calling page from the custom control ieAnyone have any ideas, simple solution would be good !!  This is the code I have myControl.ascx.vbPublic Partial Class myControl    Inherits System.Web.UI.UserControl    Protected Sub testButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testButton.Click        'call save function on PersonalDetails.aspx.vb  &...

inserting record present in one gridview in one page into gridview in other page
hi,i have two .aspx pages.one page(watch.aspx) have gridview with fields  given below.the fourth column is a hyperlink column                                                        watch.aspx                      ...

Getting a Page Control property from Custom Code
Greetings all, I have several controls (add/delete/submit buttons, gridview to name a few) in my default.aspx page.  What I want is to be able to get the properties of these controls from a custom class in my BLL folder, and eventually change their properties accordingly. Could someone show me how I can do that? Thanks. Sorry if I have to ask again, but I really need help on how (if possible) I can access and change a web page's web control (button, grid, etc) property from a custom class.  Please if you know how to do this or can point me to a link to resolve my p...

how to get the path of page which contain the custom control?
When I drag a custom control onto aspx page, I have written a UIEditor class to edit property of my custom control, but how to get the path of aspx when I open the UIEditor form? I have tried many ways, but still have no idea.  Please help me... If you mean "UITypeEditor" class, it is designed to be used only from the Properties Editor. The design mode application (VS.NET, WebMatrix, etc) locates the correct type from the [Editor()] attribute associated with a specific property. The PropertiesEditor uses that UITypeEditor object to build the UI and already has an instance of the web ...

How to switch the visibility of a custom control while still get all the Javascript functionality included with that custom control?
Hello All, I have a custom DatePicker control which works well in the past non-AJAX aspx pages, and it also works in UpdatePanel as long as the initial Visible Property is set to true. But I need to set the initial Visibility to False, make it visible if user want to input a date (such as From XX Date To XX Date in a query ), and make it invisible if the user decide not to enter a date. It looks like the javascript used by the DatePicker control won’t be loaded if the initial Visible Property is set to False.  Here is the scenario: 1. Put a custom DatePicker...

want to call one c#.net function in one user control from another user control
hi i have two user controls info.ascx and personal.ascx i have a function like in info.ascx i have a function like showdetails() {   } now i want to access this function from personal.ascx can i do this ? thanks in advance. shwetaThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path  you should better create a class where you will define the "functions" that you need in both files. declare "static" the function and call it like nameofclass.nameoffunction In a web project you can...

Web resources about - How to get custom paging like the one in this forum - asp.net.presentation-controls

Customs - Wikipedia, the free encyclopedia
The movement of people into and out of a country is normally monitored by immigration authorities, under a variety of names and arrangements. ...

Custom - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

It's coming: the custom and cut-price coffins boom
Forget the traditional silver casket, now you can get a budget coffin or one decorated in NRL colours.

Here's the tip: US custom is a grey area
When should you tip? In Australia, I think the answer is, whenever you feel the service has been better than average.

Dow Jones CEO Says Company Has Played Catch-Up On Custom Content, Isn't Worried About Ad Blocking
... and Communications Conference. "We're now making up for lost time." "There is a bit of a revolution going on in advertising, led by this custom ...

Sapphire Readies Nitro R9 Fury: Custom Design and Enhanced Performance
... is preparing to release its new graphics card — the Nitro R9 Fury — based on AMD’s Fiji graphics processing unit that features its own custom ...

Chrome Beta v48 adds custom notification buttons, Presentation API support and more
... other compatible devices. This version now allows mobile sites to present to Google Cast devices. Also new in this update is support for custom ...

Want some good vibrations? Set up custom vibrations for iPhone
Creating custom vibrations on your iPhone makes it easy to separate your notifications and ensures you don’t miss a notification, even when your ...

Audiodraft Offers A Custom-Made Solution For Advertising And Music Industry
... as a full part of a company branding. "Many businesses are still missing a clear sonic identity despite the fact that the impact of customer ...

Microsoft will offer custom Windows 10 to the Chinese government
... latest operating system directly to the government agencies. The Verge has reported how the Redmond-based software company will deploy a customized ...

Resources last updated: 1/2/2016 3:47:24 AM