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


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Paginaton in DataList

Posted By:Amitesh Kaushik       Posted Date: October 10, 2010    Points: 5    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

DataList Does not have built in Paging facilities as GridView following Code may help you out
 

private void BindForPaging()

{

   PagedDataSource pds = new PagedDataSource();

   pds.DataSource = ds.Tables[0].DefaultView;

   pds.AllowPaging = true;

   pds.PageSize = 3;

   pds.CurrentPageIndex = currentPage;

   ViewState["PageCount"] = pds.PageCount;

   DataList1.DataSource = pds;

   DataList1.DataBind();

}

ButtonNext_Click()

{

   currentPage=currentPagr+1;

   BindForPaging();

}

ButtonPrev_Click()

{

   currentPage=currentPage-1;

   BindForPaging();

}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

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