Solved

Datalist paging

Posted on 2011-02-27
3
505 Views
Last Modified: 2012-06-27
How can I enable paging in datalist control in asp.net 4.0? please give me a c# sample.

thanks

ayha
0
Comment
Question by:ayha1999
3 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 100 total points
ID: 34991852
0
 
LVL 13

Accepted Solution

by:
agarwalrahul earned 150 total points
ID: 34994192
0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 34994921
Hi,

First you can write region like this
#region PagedDataSource
    PagedDataSource _PageDataSource = new PagedDataSource();
    #endregion

Open in new window

You just put the Following Code in BindItemsList()

 _PageDataSource.DataSource = DSnew.Tables[0].DefaultView;
            _PageDataSource.AllowPaging = true;
           [b] _PageDataSource.PageSize = 12;[/b]  // Define Page Size what you want.
            _PageDataSource.CurrentPageIndex = CurrentPage;
            ViewState["TotalPages"] = _PageDataSource.PageCount;
 this.lblPageInfo.Text = "Page " + (CurrentPage + 1) + " of " + _PageDataSource.PageCount;
            this.lbtnPrevious.Enabled = !_PageDataSource.IsFirstPage;
            this.lbtnNext.Enabled = !_PageDataSource.IsLastPage;
            this.lbtnFirst.Enabled = !_PageDataSource.IsFirstPage;
            this.lbtnLast.Enabled = !_PageDataSource.IsLastPage;

            this.dListItems.DataSource = _PageDataSource;
            this.dListItems.DataBind();
            this.doPaging();

Open in new window

0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question