AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Dynamic Paging For DataList Control with PagedDataSource
Posted by Moderator1 on 5/31/2008 9:40:58 AM Category: ADO.NET
Total Views : 120897
Add to my favorites
Email to friend
  
Introduction
DataList is a data bound list control that displays items using certain templates defined at the design time. The content of the DataList control is manipulated by using templates sections such as AlternatingItemTemplate, EditItemTemplate, FooterTemplate, HeaderTemplate, ItemTemplate, SelectedItemTemplate and SeparatorTemplate. Each of these sections has its own characteristics to be defined but at a very minimum, the ItemTemplate needs to be defined to display the items in the DataList control. Other sections can be used to provide additional look and feel to the DataList control.

PagedDataSource, is a class that encapsulates the paging related properties for data-bound controls such as DataGrid, GridView, DataList, DetailsView and FormView that allow it to perform paging. And this article is going to combine both DataList control and PagedDataSource class to explain dynamic or custom paging methods for Asp.Net developers.

For demonstration, we are going to list out all the countries in the Country Table. We are going to create a dynamic paging control for this list and define the page size at run-time from a DropDownList control and enrich the navigation with Next and Previous buttons.

Do the Basics Right

Since everything comes with Ajax, create an Ajax Enabled Website, in your Visual Studio 2005. In your Default.aspx page, drag and drop a DataList control from the Toolbox, named it as dlCountry. Our country Table contains two fields such as Country_Code And Country_Name. Right click on the dlCountry datalist, choose Edit Templates > Item Template. Add two Label controls into it; bind its Text property to Country_Code and Country_Name respectively.

<asp:DataList ID=" dlCountry" runat="server"> 
 <ItemTemplate>
   <asp:Label ID="Label1" runat="server" Text='<%# Eval("Country_Code") %>'></asp:Label>     
   <asp:Label ID="Label2" runat="server" Text='<%# Eval("Country_Name") %>'></asp:Label>
 </ItemTemplate>
</asp:DataList>


Now switch to the Code-behind Default.aspx.cs, write a method to fetch data from the Country’s table.

private void BindGrid()

  string sql = "Select * from Country Order By Country_Name"; 
  SqlDataAdapter da = new SqlDataAdapter(sql, “Yourconnectionstring”); 
  DataTable dt = new DataTable(); 
  da.Fill(dt); 

  dlCountry.DataSource = dt;
  dlCountry.DataBind();


The above BindGrid method, fetches data from the Country table, bind it with the dlCountry datalist. So the dlCountry datalist is ready to display the records available in the Country table. Call this BindGrid method in the Page load event.

protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
  {
    BindGrid();
  }
}


Save everything you have done and press F5. You can see the browser opening this page and dispalys all the records in the country table. No paging available at this level.
Let us focus On Paging


To create dynamic paging, we are going to use PagedDataSource Class along with another DataList control. Drag and drop the second DataList control into the page, name it as dlPaging. In its ItemTemplates section, add a LinkButton name it as lnkbtnPaging. Set its CommandName property as lnkbtnPaging. Then choose End Template Editing. Drag and drop a DropdownList Control, name it as ddlPageSize, add values such as 10, 20 and 30 or something as you wish. Then add two more LinkButton controls. Name it as lnkbtnPrevious and lnkbtnNext and change its Text property as Previous and Next respectively. Place both the Previous and Next link buttons on both sides of the dlPaging datalist. Better I suggest you to put an Html Table control and place these controls in it properly so that it will look nicely aligned.


Now we will work little bit on the code-behind of the Default.aspx. Declare a PagedDataSource object at page scope.


PagedDataSource pds = new PagedDataSource();


Then declare a public property called CurrentPage to maintain the latest selected page index. Selected page index is stored in a ViewState variable. The default value of the ViewState is 0.


public int CurrentPage
{

  get 
  { 
    if (this.ViewState["CurrentPage"] == null) 
      return 0; 
    else 
      return Convert.ToInt16(this.ViewState["CurrentPage"].ToString()); 
  }

 set
 { 
  this.ViewState["CurrentPage"] = value;
 }

}
 

Next write a method ‘doPaging’ to create a list of page numbers. The total number of pages can be taken from the PagedDataSource object’s PageCount property. We create a DataTable from the information obtained from the PagedDataSource object and assign the DataTable to the dlPaging datalist.
private void doPaging()
{
 DataTable dt = new DataTable();
 dt.Columns.Add("PageIndex");
 dt.Columns.Add("PageText");
 for (int i = 0; i < pds.PageCount; i++)
 {
  DataRow dr = dt.NewRow(); 
  dr[0] = i; 
  dr[1] = i + 1; 
  dt.Rows.Add(dr);
 }

 dlPaging.DataSource = dt;
 dlPaging.DataBind();
}

Look closely, at the doPaging method. Notice the two columns such as PageIndex and PageText. Even though it is understandable, PageIndex is the selected index value of the pages while PageText is the display value in the dlPaging Now we have to bind PageIndex and PageText into the dlPaging’s lnkbtnPaging link button. So set the CommandArgument and Text property of the lnkbtnPaging to PageIndex and PageText respectively. So the entire dlPaging datalist control’s Html source code will look like follows.

<asp:DataList ID=" dlPaging" runat="server" OnItemCommand="dlPaging _ItemCommand">
<ItemTemplate>
  <asp:LinkButton ID="lnkbtnPaging" runat="server" CommandArgument='<%# Eval("PageIndex") %>' CommandName="lnkbtnPaging" Text='<%# Eval("PageText") %>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>

Modify BindGrid Method
 

The next step is to combine both the Country listing datalist and paging number datalist controls. To start this, we are going to modify the BindGrid() method slightly.


private void BindGrid()

  string sql = "Select * from Country Order By Country_Name"; 
  SqlDataAdapter da = new SqlDataAdapter(sql, “Yourconnectionstring”); 
  DataTable dt = new DataTable(); 
  da.Fill(dt); 

  pds.DataSource = dt.DefaultView;
  pds.AllowPaging = true;
  pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
  pds.CurrentPageIndex = CurrentPage;
  lnkbtnNext.Enabled = !pds.IsLastPage;
  lnkbtnPrevious.Enabled = !pds.IsFirstPage; 

  dlCountry.DataSource = pds;
  dlCountry.DataBind();

  doPaging();


In the above method, as usual we fetch data from the Country table and filled it in a DataTable. Then we assign it to the DataSource of the PagedDataSource object pds. Set its AllowPaging property to true and its PageSize with the value from the ddlPageSize DropDownList control. CurrentPageIndex is assigned with our pre-defined property CurrentPage. When the page index reaches first and last page, our Previous and Next button should be disabled. So in the next two lines we check the pds whether it reaches Last or First page, accordingly we set their Enabled property. Now everything is ready to assign the pds to our Country Listing DataList. Last but not least, we are calling the doPaging method to create page numbers.



Paging Events

In the ItemCommand event of the dlPaging control, write code for the paging to take place. Here we take the PageIndex value from the CommandArgument of the lnkbtnPaging and assign it to the CurrentPage property. On every event, we call the BindGrid method.


protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
 if (e.CommandName.Equals("lnkbtnPaging"))
 {
   CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
   BindGrid();
 }
}

Previous And Next Button Events


In the Click events of the lnkbtnPrevious and lnkbtnNext, write a line of code that decrease and increase the value of CurrentPage property.


protected void lnkbtnPrevious_Click(object sender, EventArgs e)
{
  CurrentPage -= 1;
  BindGrid();
}

protected void lnkbtnNext_Click(object sender, EventArgs e)
{
  CurrentPage += 1;
  BindGrid();
}


Change PageSize Dynamically


To change the PageSize of the PagedDataSource dynamically, we have to call the BindGrid method again because we have already assign the value of the ddlPageSize to the PageSize property of the PagedDataSource.
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
  CurrentPage = 0;
  BindGrid();
}

HighLight Selected Page Numbers


To inform the user about the selected page, we have to highlight the Page Number in different style. This can be achived by using the following code in ItemDataBound event of the dlPaging datalist.


protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
{
  LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging"); 
  if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString()) 
  { 
    lnkbtnPage.Enabled = false; 
    lnkbtnPage.Font.Bold = true; 
  }
}


That’s it. Save everything and hit F5. You can see first DataList will display first 10 Records from the Country Table. The dlPaging control will populate the list of page numbers. Previous button will be in disabled state while Next button is active. Click on any page number, Page will navigate for the Page you choosed. Try by clicking Next and Previous buttons, then Change the ddlPageSize value.

To enable Ajax to this page, add the ScriptManager and include all the control inside an UpdatePanel. Its done.


Finally, this article is just a sample for tutorial purpose. You can customize the paging as you like using the above technique.

Click here to view our DataList Paging Demo Page
Viewer's Comments
Posted by Minhaj on 6/10/2008 4:44:42 AM
Nice Article Thank You Very Much Thanks a Lot
 
Posted by fahad on 6/12/2008 10:01:50 AM
thanks a lot man u solve my probelm i m creting my first project and very much in trouble
 
Posted by krishna on 6/12/2008 11:38:56 PM
Its a Nica article.ThankQ.
 
Posted by seko on 6/15/2008 3:19:07 PM
thank you so much it was a big problem for me paging adatasource.
 
Posted by annie on 7/2/2008 5:23:38 AM
This is very good work. I am using it in my project but i am facing 1 problem, we are using magic ajax not microsoft ajax, and it is not working properly with magic ajax. Kindly give me any suggestion.
 
Posted by Imran Ahmed on 7/4/2008 11:51:22 PM
Excellent article, I tried and it works perfectly. It saved lots of my time. Please keep up the good work. Thanks
 
Posted by ashok on 7/23/2008 12:30:01 AM
i want to download working code for this which am not able to fine on this site, please help me
 
Posted by Nikhil Patel on 7/29/2008 6:13:58 AM
Hi,, It's nice artical which is very helpful to me.
 
Posted by RK on 7/31/2008 1:16:40 AM
Excellent! It is very helpful to me.
 
Posted by herrjj on 8/11/2008 1:39:18 PM
Thanks for this. Very helpful. Word of warning for copy/pasters; there are some spaces that may casue some trouble. In the line below, I placed capital X's where the spaces are: Be sure to pull them out...
 
Posted by herrjj on 8/11/2008 1:40:04 PM
DataList ID="XdlPaging" runat="server" OnItemCommand="dlPagingX_ItemCommand"
 
Posted by Humayun Rashed(KUET Bangladesh) on 8/18/2008 3:14:52 AM
Thankx a lot. this is very easy way for paging of datalist.
 
Posted by syed mohamed on 8/30/2008 4:53:33 AM
how to custom paging in datagrid using c# coding
 
Posted by Harris on 9/2/2008 12:33:04 AM
its a fine one........thank u very much......
 
Posted by Karthi on 9/10/2008 7:17:33 AM
It's excellent articles......thanks a lot
 
Posted by yogesh on 9/18/2008 3:21:23 AM
i want some help on the above list. suppose there is an item descprtion that is viewed on a different page and want to come back, i can come back to the list view again. but the problem is if i select an item in the 2 page list and view details and come back i come back to the list view of page 1 only. can you help me out
 
Posted by roman on 9/18/2008 4:12:18 PM
this is the best article on the subject, i spent hours trying to find a solution to the paging problem, and you made it very easy. thanks much !!!
 
Posted by Raghu on 9/23/2008 6:10:53 AM
Very nice, what if i want to fix the number of pages displaying in second datalist once i click next it should replace the existing numbers with continuous number some what like << < 1 2 3 > >> when clicked next it should be display like << < 4 5 6 > >>.
 
Posted by prasanth on 9/23/2008 7:47:38 AM
this will be very useful for my requirement ,thank you for providing info
 
Posted by miladhatam on 9/26/2008 11:29:14 PM
hi it dosn't work !
 
Posted by Dboy on 9/27/2008 12:10:33 AM
I am having issues implementing this code. It appears that when assigning the declared dt to the PageDataSource object it returns all records (even though you specify the number of records to return for a single page with pds.PageSize). Please clarify or advise. Thanks.
 
Posted by karthik on 10/3/2008 2:45:55 AM
Very nice, what if i want to fix the number of pages displaying in second datalist once i click next it should replace the existing numbers with continuous number some what like << < 1 2 3 > >> when clicked next it should be display like << < 4 5 6 > >>
 
Posted by Keivan Sadralodabai on 10/3/2008 11:59:19 AM
A very well written, easy to understand, and informative article. Nice to know I don't have to write custom paging controls for repeaters.
 
Posted by Afsal on 10/7/2008 10:41:56 AM
Nice Nice...
 
Posted by sree on 10/21/2008 9:13:47 AM
my question is how to show page count to the datalist like 1,2,3.. by clicking on .. i should get 4,5,6 can u plz help me on this
 
Posted by kennethdas on 11/5/2008 4:04:32 AM
excellent article..........simple and upto the mark....keep ur good work
 
Posted by Hemakumar on 11/5/2008 5:29:41 AM
very good article...... but i am not getting that page nos plz help me
 
Posted by sachin patil on 11/13/2008 11:44:48 PM
Looks great,
 
Posted by mahalakshmisethu on 12/1/2008 7:04:28 AM
hi.. very good article.it is very useful. i have done it with repeater control. Thanks.
 
Posted by JP van Schalkwyk on 12/3/2008 5:39:46 AM
Very Nice
 
Posted by Muthu vijayan on 12/12/2008 4:39:51 AM
nice work man !
 
Posted by Pradipta Sutar on 12/19/2008 6:05:06 AM
Very nice, what if i want to fix the number of pages displaying in second datalist once i click next it should replace the existing numbers with continuous number some what like << < 1 2 3 > >> when clicked next it should be display like << < 4 5 6 > >>
 
Posted by Tejas Joshi on 12/22/2008 5:55:39 AM
Great, It is a simple example for datalist paging and also very easy to understand. Thanks a lot.
 
Posted by Akhilesh Soni on 1/14/2009 7:53:31 AM
Its really very good work
 
Posted by 10 on 1/22/2009 12:49:28 AM
u r so cleaver, iit is very useful
 
Posted by ved on 2/4/2009 1:47:30 AM
Thanks, very good article..
 
Posted by jitendra on 2/5/2009 1:26:26 AM
Great Article, Really Apprecitable, fantastic. Solved my biggest problem Thankyou very much.
 
Posted by praveen on 2/12/2009 6:43:36 AM
this code how to write in edititem template
 
Posted by John on 2/14/2009 3:30:37 PM
Very well done, It works.
 
Posted by Juraj on 2/19/2009 8:34:44 AM
well done, lovey article. works well and is simple to implement :)
 
Posted by BBRAO on 2/25/2009 3:34:42 AM
Excelent work we can use this concept for multiple pagings
 
Posted by premjii on 3/2/2009 5:52:36 AM
good job . very useful to us..
 
Posted by ali on 3/3/2009 7:40:03 AM
where i can download it zip file .. for this project ???? please ..
 
Posted by joohitha on 3/4/2009 4:53:20 AM
if we have more than 10,000 records and per page we are displaying 20 records. so total 500 pages will be binded(in first page) in the datalist control it self.How to slove this problem? ex: 12345678.......212 213...... like in the same row
 
Posted by polskie strony internetowe on 3/4/2009 10:50:31 AM
good job . very useful to us.. works well and is simple to implement :)
 
Posted by Neg on 3/30/2009 2:44:13 AM
I want this complete code how i can download u can help me please
 
Posted by laxman on 4/1/2009 4:11:26 AM
Excelent work we can use this concept for multiple pagings
 
Posted by Diwakar on 4/4/2009 12:56:24 AM
Grate work thanks......................!!!
 
Posted by Abhilash on 4/13/2009 2:10:59 AM
Great Article. Im using this piece of code. Thanks. I'm impressen by your idea. Tc.
 
Posted by rimple on 5/4/2009 6:13:00 AM
if i want to put arrow image while pagging than??
 
Posted by Afzal on 5/7/2009 5:40:30 AM
This seems a very good and easy article. But I am having an issue implementing this. I converted the code to vb.net and I failed when I tried to refer the linkButtons within the dlPaging DataList. Can you please help in this regard.
 
Posted by Nitin Sinha on 5/20/2009 6:41:41 AM
thanx for help by code. i m very much found of pagging in datalist.
 
Posted by Rohit on 6/6/2009 4:30:34 AM
thanx... this was nice code
 
Posted by sujatha on 6/13/2009 6:17:59 AM
Great article.Very nice.Thank you.
 
Posted by ashish on 6/15/2009 5:12:26 AM
Hi all, can plz someone help on how to page a repeater bound to sql data source.. thnx in advance:)
 
Posted by pavani on 6/30/2009 8:05:18 AM
i was new this concept of Paging in datalist it has helped me now i have problem in the datalist control where am having checkboxs when i check and click on next page i lose state of the check box i donot want that how is it possible can any one help me jst give me any idea tahnks in advance
 
Posted by prabhakar on 7/5/2009 11:38:36 PM
This article is very good thanks for helping me
 
Posted by faith on 7/20/2009 12:55:25 PM
Thanks for this article. It has helped me a lot. Blessings!
 
Posted by riyas on 7/22/2009 11:18:28 PM
Good one
 
Posted by Alee on 7/23/2009 8:21:56 PM
Have anyone found the questions asked above of showing limited amount of page numbers like << < 1,2,3,4,5 > >> and then << < 6,7,8,9,10 > >> ??? I have a huge number of records in my table and it will show 100+ page numbers in the paging... What is the solution?
 
Posted by xxx on 7/27/2009 8:53:49 AM
pls check this link .............. http://aspalliance.com/articleViewer.aspx?aId=157&pId= Get the Ans of paging in Datalist
 
Posted by Jamie on 8/3/2009 9:58:13 PM
neat... we don't have to deal with the data layer using store_proc or something... Thanks...
 
Posted by Smikesh on 8/4/2009 3:50:50 AM
Great work.
 
Posted by brij on 8/17/2009 2:24:38 AM
it 's such a very helpful for beginners
 
Posted by Yaniv on 8/19/2009 2:58:04 AM
Excellent work. It was very helpfull. Thanks. Yaniv
 
Posted by anitha on 8/30/2009 11:55:05 PM
Nice coding
 
Posted by rajan on 9/16/2009 6:23:36 AM
hey thats very useful with me but above code i cant get 12345 like this for this what can i do told me pls
 
Posted by hara on 9/22/2009 10:13:25 AM
Thanks you, It works!! Nice coding :3
 
Posted by Saurabh on 9/23/2009 9:26:36 AM
Thanks a lot.. This is what I'm looking for........ Great work... appreciated..
 
Posted by Dj on 10/1/2009 5:59:24 AM
COOL>>>>>>>>
 
Posted by Rakesh kumar on 10/11/2009 1:33:09 AM
Thanks lot.Paging in Datalist was big problem for me.. I was searching code for same.I would be greatful to you if I can get complete code how I can download please suggest me?.Thanks once again .
 
Posted by Anish on 11/6/2009 4:06:01 AM
Very Nice & Excellent work
 
Posted by Yussi Ariefiyono on 11/10/2009 4:59:39 AM
you can also change the next and previous button with lnkbtnNext.Visible = !pds.IsLastPage; lnkbtnPrevious.Visible = !pds.IsFirstPage; so when it is last page, the next button will be gone. same as when its first page, the previous button will be gone. enjoy! cheers!
 
Posted by adesh on 11/18/2009 9:05:16 AM
Very Helpful Article...thanks
 
Posted by Lisseth on 11/26/2009 1:30:26 PM
Very useful article. Thank you.
 
Posted by Lisseth on 12/14/2009 5:13:59 PM
Can I change the linkbutton control of dlPaging and put a hyperlink control?
 
Posted by Rupesh Deshmukh on 12/20/2009 1:27:42 AM
it was excellent as it works nicely for any required application
 
Posted by surya on 1/28/2010 2:25:12 AM
Great one .............thanks a lot...................
 
Posted by vamsi on 2/12/2010 7:53:52 AM
Hi i have problem in dyanamic paging. Buttons displaying based on columns is good but i seen allthe data in every page. for ex: i give page size is 1 i have 4 records. 4 buttons is created its fine but which button i click all the data is seeing i want to know the error
 
Posted by Bhavin on 2/25/2010 5:33:52 AM
Nice one man... Good
 
Posted by John on 2/27/2010 10:29:16 AM
this is an awesome article. thanks
 
Posted by Jason on 3/9/2010 5:14:28 PM
This is a well done article and the code works, one small bug for (int i = 0; i < pds.PageCount - 1; i++) I think there should be a minus one on pds.PageCount-1. Here is the page I implemented it one http://www.prop2go.com/SearchApartmentResults.aspx?type=Apartments_For_Rent&city=Ottawa Thanks, Jason www.prop2go.com
 
Posted by @ Jason on 3/10/2010 3:42:24 PM
Your google ads are distracting I almost click on it. Seriously don't let your site look cheap.
 
Posted by Charlie on 4/6/2010 11:49:13 AM
Hi, I would dearly love to make this work. Am using VWD 2008 express. I have the following error / exception when debugging the first stage of the lesson ( no code re paging and no second datalist added at that stage. "Format of the initialization string does not conform to specification starting at index 0." Related to the following line of code: SqlDataAdapter da = new SqlDataAdapter(sql, "ConnectionStrings:ConnectionString"); I copied Exception detail to c
 
Posted by Matt on 4/15/2010 12:34:39 PM
Stupendous article. Much much thanks!!!
 
Posted by Charlie on 4/15/2010 1:27:00 PM
Fantastic - one more very grateful reader. THANKS !! Can anyone offer any help re adding a where clause to the select statement. I get the "must declare the scalar variable" somewhere in Private Void BindGrid(). Not much room for comment here so Directions to another lesson would be good XX
 
Posted by javad on 4/19/2010 1:45:49 PM
hello. i have an Idea!! instead of these long coding and control manipulation , use a gridview with a template column that contains all of datafield that we need to show and bind them. then set the property of paging in gridview to true.that is allllllllllll!! no need to Mühe
 
Posted by furqan on 4/21/2010 5:37:50 AM
not working..i just copy paste all the code..still not working...
 
Posted by Tabrez on 4/23/2010 8:07:57 AM
hi, i have read this article and implement it. it's working fine. good job....friend :)
 
Posted by kaustubh shukla on 4/27/2010 1:54:44 AM
The code is working fine but page numbers are vertical and not horizontal... what would be the problem
 
Posted by Faiz on 5/13/2010 1:20:56 AM
Hey kasustubh use RepeatDirection = "Horizontal" for the datalist where datalist id = dlPaging u will get horizontal alignment for paging numbers
 
Posted by King on 6/11/2010 6:05:41 AM
Nice work
 
Posted by Annu on 7/8/2010 1:58:52 AM
Nice one................
 
Posted by Neha on 8/13/2010 2:30:23 AM
nice article.very helpful!!!
 
Posted by Rishika on 9/23/2010 7:10:50 AM
Really very helpful article
 
Posted by Shiva on 9/23/2010 7:32:25 AM
Great work, its working nicely
 
Posted by negative infinity on 9/27/2010 6:09:35 AM
never again post such damn stinging stuffs!
 
Posted by Hari on 9/27/2010 6:11:23 AM
wats this ?????? very poor .......
 
Posted by harisanker on 9/27/2010 6:15:46 AM
very much entertaining ... very good article for wasting time
 
Posted by Murali on 9/27/2010 7:16:09 AM
It's really very nice... It saves my time..... Excellent work....
 
Posted by Prasad on 10/13/2010 4:43:58 PM
Thanks I am searching for it. Helpful article Keep it Up.
 
Posted by archana on 10/20/2010 3:28:33 PM
thanks a lot
 
Posted by Adit Shah on 10/27/2010 3:37:47 AM
Nice Article. Have anyone found the questions asked above of showing limited amount of page numbers like << < 1,2,3,4,5,6,7,8,9,10 > >> and then << < 11,12,13,14,15,16,17,18,19,20 > >> ??? I have a huge number of records in my table and it will show 200+ page numbers in the paging... What is the solution?
 
Posted by mary on 10/27/2010 4:12:05 AM
thanks so much
 
Posted by Bilguun on 11/14/2010 8:09:30 AM
cool. it is awesome. but i have a problem with ItemDataBound event when i compile. the error is System.NullReferenceException: Object reference not set to an instance of an object at if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString()) { lnkbtnPage.Enabled = false; what is happened, what should i do help me.
 
Posted by Bilguun on 11/14/2010 8:11:08 AM
if its quite alright send me email thank you
 
Posted by Mahmoud Algoul on 12/6/2010 2:22:28 AM
cool article, do you have the full source code to download please
 
Posted by vamcogame on 12/8/2010 9:22:53 PM
thanks , it's very cool.
 
Posted by Vivek on 12/30/2010 12:46:57 AM
fine.. But im Having Simple Idea...
 
Posted by monika on 1/15/2011 3:36:09 AM
Very good article....and very simple..
 
Posted by Pradeep on 2/14/2011 5:40:30 PM
Great Article, can you please send me the code to my Email Id Mentioned Thnks
 
Posted by santhosh on 3/24/2011 12:47:54 AM
Excellent article. It is very helpful to all .net developers.
 
Posted by sachin on 3/29/2011 11:27:47 PM
Excellent Article its very helpful. but i want one more thing here i want checbox with paging and i want to retain checkbox checked in paging event how can i do it.....help me
 
Posted by Ghouse on 5/3/2011 3:16:29 AM
Very nice article. It helps me a lot. i was looking it for many days Thanks.
 
Posted by Bongoon on 6/11/2011 4:35:59 AM
Datalist source should look like this for itemdatabound event to work, for changing font style of selected page <asp:DataList ID="dlPaging" runat="server" OnItemCommand="dlPaging_ItemCommand" OnItemDataBound="dlPaging_ItemDataBound">
 
Posted by Mohammed Mujtaba on 6/14/2011 4:52:02 PM
Very nice artical, looks like it was made for me. Jazzak Allahu Khair.
 
Posted by Elena on 6/17/2011 3:08:29 PM
This article is great - timeless! I have finished in one hour changes for my project. Thank you! Elena
 
Posted by kiran on 7/30/2011 4:08:36 AM
can u provide the source code of same
 
Posted by rkthiyaku on 8/31/2011 4:36:23 AM
very nice...thanks alot
 
Posted by bhargav patel on 9/6/2011 4:26:13 AM
can you give me full source code i cant get it exectly
 
Posted by sharad sharma on 11/10/2011 8:19:12 AM
Nice and well manage article that really provide proper guidence and understandble .Keep Posting
 
Posted by Kevin on 1/10/2012 11:15:46 PM
Got a problem. I am getting an error code:- DataSource Controls :: System.ArgumentException: Format Of The Initialization String Does Not Conform To Specification Starting At Index 0 Anyone help with this thanks
 
Posted by clyde on 2/8/2012 9:43:52 PM
hi buddy!you know what?your a blessing from the heavens!You have solved my problems!!!!!GOD BE WITH YOU!!!
 
Posted by chirag on 4/8/2012 9:35:26 PM
thanx but i have problem i want to use datalist item click event using commadname property ...which is not possible??
 
Posted by Emile on 6/4/2012 6:02:42 AM
Excellent work , thanks a lot !
 
Posted by touinta on 6/6/2012 6:12:22 AM
Great example! Is there somewhere the code available for download? Thank you
 
Posted by viniston on 6/18/2012 6:25:40 AM
this is a very good article for all. thanks a lot
 
Posted by Luiz Estevo on 8/1/2012 1:19:56 PM
Man, You are my Hero! What such a great, simple and clean solution. I have already tested it and it works like a charm. I am implementing it on my site today. Thanks a bunch and keep up the good work. Luiz Estevo www.homestayconnection.ca
 
Posted by 10outof10 on 9/22/2012 5:51:17 AM
Dude u r a real hero Thank u so much
 
Posted by priya on 11/5/2012 4:03:58 AM
excellent
 
Posted by Thiri on 1/9/2013 3:05:01 AM
Really nice
 
Posted by Michael on 4/28/2013 1:41:22 PM
Wonderful send me the code thx~ since so much people command,i try on it and i believe not much people able to display the output! appreciated ~ michael.cheong@hotmail.com send me the code thx~
 
Posted by Nikhil on 7/8/2013 1:43:20 PM
Great Article...but i have a small problem implementing. Im my case the code used to fetch the data is inside the "Linkbutton_Click" event function (in your case its "doBinding") and hence im not able to call the function from all the other Event handlers like dlPaging_ItemCommand etc. because of the arguments(object sender,EventArgs e) Please help !!
 
Posted by Aayushi Jain on 7/16/2013 11:23:47 AM
Thanks a ton for this article. It helps me a lot!
 
Posted by DaveyL on 11/23/2013 1:16:11 AM
Excellent. Very elegant solution.
 
Posted by gowtham on 3/31/2014 6:53:22 AM
excellent job! fantastic.. thool ma thool ..
 
Posted by gowtham on 3/31/2014 6:53:23 AM
excellent job! fantastic.. thool ma thool ..
 
Posted by gowtham on 3/31/2014 6:53:24 AM
excellent job! fantastic.. thool ma thool ..
 
Posted by sunil kumar on 4/16/2014 8:34:11 AM
THANKS ..........GREAT HELP ME
 
Posted by sunny patel on 6/23/2014 6:37:07 AM
this is good for less number of pages/ but for large number of pages its not working.. is displaying all number of pages like 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 but its nor perfect. please modify this code for around 100 pages. I want to need Like this: Prev 1 2 3 4 5 ... Next
 
 Rating & Comments
A word 'Excellent' means lot to the author of this article. You can give comments about this article but not the author.
Rate this Article:
Name:
Email Id:  
We never display your email id anywhere.
Comment/Question: Max. 500 letters
Twenty-One plus Six Equals To
 
 
Sponsored by
The Beginner's Guide to Joomla
Oracle Magazine
Everything You Know About CSS Is Wrong! - Free 37 Page Preview!