Thread: Datalist Paging
View Single Post
  #2 (permalink)  
Old August 9th, 2007, 08:24 AM
gaurav_jain2403 gaurav_jain2403 is offline
Friend of Wrox
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403

You are refraining from using heavy code. But, not to disappoint you, achieving paging in datalist require hard work from you. You have to maintain few things in ViewState variable like the current page index, size of page(optional). You will have to check the number of rows returned by your query and accordingly, you will have to display that many links in footer. Also, You can add Four buttons in the footer i.e. First, Last, Next, Previous.

The other important thing is that you should always update the viewstate variable smartly. Use SqlDataAdapter1.Fill(DataSet1,startIndex,PageSize, "TableName"); to fill your dataset and bind that dataset to your datalist.

This is the logic you have to use. You can also search google, you will find source code there.