.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Datapager NextPreviousPagerField

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :ASP.Net


I want my datapagers previous linkbutton not to be shown in the start. it must only become visible when you 
have cliked the linkbutton (next)

I want my datapagers previous linkbutton not to be shown in the start. it must only become visible when you have cliked the linkbutton (next)


View Complete Post

More Related Resource Links

GridView with DataPager in ASP.NET 3.5

To page through data in a control that implements the IPageableItemContainer interface, DataPager control can be used. GridView has its own paging and does not implement IPageableItemContainer interface. ListView is the only control that works with DataPager.

The DataPager control supports built-in paging user interface (UI). NumericPagerField object enables users to select a page of data by page number. NextPreviousPagerField object enables users to move through pages of data one page at a time, or to jump to the first or last page of data. The size of the pages of data is set by using the PageSize property of the DataPager control. One or more pager field objects can be used in a single DataPager control. Custom paging UI can be created by using the TemplatePagerField object. In the TemplatePagerField template, the DataPager control is referenced by using the Container property which provides access to the properties of the DataPager control. These properties include the starting row index, the page size, and the total number of rows currently bound to the control.

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

Add tooltip to ASP.NET Datapager

Here is the sample code of javascript and data pager.

ASP.NET pager doesn't provide any direct support for adding tooltip to its different buttons . But there are some work arounds through which you can provide tooltips to ASP.NET data pager.

The structure of a simple data pager is as follows:


RenderDisabledButtonsAsLabels="true" ShowFirstPageButton="true" ShowPreviousPageButton="true"
ShowLastPageButton="false" ShowNextPageButton="false" />
NextPreviousButtonCssClass="command" />
RenderDisabledButtonsAsLabels="true" ShowFirstPageButton="false" ShowPreviousPageButton="false"
ShowLastPageButton="true" ShowNextPageButton="true" />

But How ever it provides CSS classes for all set of buttons. And in the page it is rendered as simple span and anchor link. If we are giving some unique class to all buttons present in the data pager and through javascript we can retrive the elements and we can assign Tool Tip to

ListView DataPager with SQL-Statements that already return only paged data.



As far as I understand the ListView-Control and the DataPager-Control, they work like this: The ListView gets its datarows from its data source, then the DataPager causes the ListView to display only a subset of those rows.

So what, when I want to use custom databinding for the ListView, that *already* gets the certain subset from SQL-Server (for better performance). Can I and how can I use the DataPager then?

Thanx, S.

Display a nested child ListView on PostBack while using DataPager on parent ListView


Hello ASP.NET community,

I am having trouble finding how to solve the following issue :

I am using nested listviews to display Sales and Sales details.

The main ListView displays General Information about Sales and the child ListView displays the detailed information about one sale. the child listview is shown only when the user clicks on a link (see included code, DataBind is made on PageLoad) :

ASPX Markup Code :

<asp:listview id="lvSales" runat="server" onitemdatabound="lvSales_ItemDataBound">
<table cellspacing="0" border="1" width="250" style="border-collapse:collapse;">
<tr runat="server" id="headerRow">
<th scope="col" style="width:30px;"></th>
<th scope="col">SaleNumber</th>
<tr id="itemPlaceHolder" runat="server" enableviewstate="true"/>
<tr id="row" runat="server">
<td style="text-align:center;"><asp:button id="btnShowHideDetails" runat="server" oncommand=&qu

Exception caused by DataPager.SetPageProperties() on ListView (postback error)

 Hi, I have a issue with drives me crazy! I'm using the DataPager method SetPageProperties() to restore the current page in my listview after I navigated into a page related to a listview item. (I persist the current page in the session state) I display 10 items at a time, and there are 10 pages. Everything works perfectly for the first 100 items, .... but after I go beyond (to display pages 11 to 20), if I call SetPageProperties() to restore the proper "current" page, I cannot submit anymore anything without getting the following exception: An error has occurred because a control with id 'ctl00$ctl00$ContentPlaceHolder$ContentPlaceHolder1$m_ListViewSearchItems$lvProductsPager$ctl00$ctl10' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error. The exception refers to the DataPager sub-controls which are not rendered the same way for first pages (1 - 10) than (11 - 21); Is that because it expect then a "previous page" button? I don't quite know what to think about it. Does anyone have a clue?

URL Routing + DataPager control

hi all, we are using URL Routing so a path like http://www.mysite.com/news/Default.aspx would be output like http://www.mysite.com/news we have a data pager on the page that ties to the list view. the data pager when changing pages reverts the url back to the un-routed version (like http://www.mysite.com/news/default.aspx?page=2) how can i re-write this back to something more friendly for my app ideally it would be great to have it look sometihng like /news/page/2  i can use IIS 7's new re-write module - already using it to remove trailing slashes. thanks in advance, mcm  

ListView with DataPager

Hi, i use a ListView with DataPager but fail when change page in the DataPager because does nothing. Producto losProductos = new BLL.Producto(); ListView1.DataSource = losProductos.TraerTodos(); //List<Producto> ListView1.DataBind();   <asp:ListView ID="ListView1" runat="server"> <LayoutTemplate> <ul class="ulproduct"> <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> </ul> </LayoutTemplate> <ItemTemplate> <li> <table width="100%"> <tr> <td rowspan="3" class="style1"> <img class="img" src='<%# string.Format("/SirPet.com/img/productos/{0}.jpg", Eval("Codigo")) %>' alt='<%# Eval("Codigo")%>' height="90" width="60" /> </td> </tr> <tr> <td colspan="2">

finger swipe on ipad/iphone for datapager control


hi all,

i am currently develping a webpage for ipad/iphone user, but the problem now i face is adding the finger swipe feature for the datapager control, if the user swipe finger to the left, i want the pager to go previous and swipe right side for the next page.

after i research, i got the code for swiping using javascript,  when swiping different direction, the background of the page will be changed, but i just dont know how to implement the code to my datapager control, please help me, thank you.



 <script type="text/javascript">

      // this script can be used with one or more page elements to perform actions based on them being swiped with a single finger

      var triggerElementID = null; // this variable is used to identity the triggering element
      var fingerCount = 0;
      var startX = 0;
      var startY = 0;
      var curX = 0;
      var curY = 0;

ListView, DataPager, LinqDataSource: LinqDataSource Selecting event fire twice


Dear all,

In my web app, I used LinqDataSource, ListView and DataPager (.NET 3.5 sp1) to implement search feature with paging. I have a button to trigger the search.

But In the first time, the Selecting event of LinqDataSource fire twice and I don't know why (I debugged my code very carefully). I don't use QueryString with DataPager and assign PageSize of DataPager in the first time of page load to prevent the ListView bind again (as in some instructions I found in forum)

Have anyone seen this problem before? And If possible, can you give me some instructions to try?

I can't post my code because it's quite large.

Thank you very much


Developer, CSC Vietnam


How to set DataPager Width



is there any chance to set DataPager width to 100% or to a static width of some px?

DataPager Manual input From Listview Control


Hi There,

I've been trying to marry up the listview and the Data pager with my own, Database class that pulls the information from the database.

I can display the information ok no problem, fortunately this time I know what the problem is, but I cannot figure out a way around the problem.

In my Page_Load event I fill out the listview accordingly:


Dim mList As List(Of Object) = mDbase.Record.Items("SELECT TBLResults.ID, Draw, [Date], B1, B2, B3, B4, B5, B6, BB, Jackpot, Wins, Machine, BallSet FROM TBLResults, TBLMachine WHERE TBLResults.MachineID=TBLMachine.ID ORDER BY Draw", GetType(ResultItem))


     Me.ListView1.DataSource = mList





The problem lies in the postback, I need to figure out a way get the information as to what state the DataPager is in so I could update the Query accordingly.

I know there is a StartRowIndex avaialbe but this does not get updated in the Page_Load event.

Has anybody got any ideas?

DataPager: raise event when page changing


I have a ListView and a DataPager beneath.

When the page is changed I bind the ListView from the PreRender event handler:

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Dim postControl As Control = GetPostBackControl(Me)
        If Not postControl Is Nothing Then
            If TypeOf (postControl.Parent) Is DataPagerFieldItem Then
            End If
        End If
    End Sub

Is there any way of intercepting an event raised when the page is changed without relying on page.PreRender?

Anyone know about DataPager in a composite control




I'm trying to use a datapager inside a composite control which references a listview inside the same composite control. Does anyone have experience with doing this as I believe I've set everything up but its not being displayed and not affecting the listView

ListView with DataPager problem on ASP.NET 4


I'm currently working on upgrading an existing ASP.NET 3.5 app to ASP.NET 4 and I found a rather odd behavior with a ListView and DataPager. I'm using a ListView with an ObjectDataSource and in the ListView I have a DataPager with a NumericPagerField. On my 3.5 web app the page will display the ListView properly and will display the page number links at the bottom, where the DataPager is located. If I go to the last page and delete row by row until all are gone, the ListView will automatically page to the previous page. This is all behavior out-out-the-box since I don't have any special code for paging.

When I run the same app on ASP.NET 4 the behavior changes. The ListView no longer automatically pages to the previous page and I'm left with an empty list, with no way to get back to the previous pages even though there is still data to be retrieved. I get no DataPager control at the bottom because at this point what the ListView is displaying is the EmptyDataTemplate.

The way I've been able to reproduce this is by creating two web apps as follows:

Using Visual Studio 2010 Premium (a release version, not a demo or preview)

Create an empty web application (I called mine WebApplication1) using ASP.NET 3.5 and create a new web form called WebForm1.aspx

Use the following code:

<%@ Page L

Listview and DataPager not playing well together


environment:  VWD 2010 Express, SQL 2008 Express, .NET 4.0, VB

ok so this is driving me nuts!  I have a page with 4 radio buttons followed by 3 cascading ddl followed by a tab container with 5 tabs.  Each tab holds a listview, etc that is particular to the group that has access to that tab.  On page load I filter the listview based on who is logged in plus which radio button and DDL is selected - all ok so far.

after the page load, the initial datapager works fine and all other listview functions are fine.  However, if I select the 4th radio button, the data returned is correct and the datapager shows as if it knows the correct number of items but if I click the datapager page 2 (or Last, etc) it immediately reloads the correct data as if it were a new page load (and changes the datapager appropriately).  My suspicions are that this is due to the declarative select command defaulting to the data that it always goes back to. 

I have tried to move the select to the code behind and played with the tabcontainer prerender event.  That eventually got me to the point where the datapager was working properly but then I could no longer edit any of the dropdowns in my listview edit screen where I could before.   They would go through the motions but as soon as you selected a new dropdown value, it would revert bac

formatting datapager text


I have a listview control qith a datapager.  I'm using a linkbutton for next and previous.  I have a css class that makes the text Arial, and bold.  It also sets the size to 10px.  When I run the page, the link button is Arial and bold, but I can't change the size of the text.  I've tried setting it to 10px, 8px, even 5px, 10pt,  and xx-small.  Nothing changes the font size. 

My customer wants the next and previous buttons to look a certain way.  I'll have to manage paging manually if I can't get this figured out. 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend