Solved

Datalist paging

Posted on 2011-02-27
3
499 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

3 Use Cases for Connected Systems

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

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now