Datasets and paging

current i have a huge database of about 1mill + records that need to be able to be broswed.

What i would like is to bring over 50 records at a time and page through the database that way and therefore limit the amount of data be returned at any one time.

Could anyone point me in th eright direct. Either to a tutorial or some source code would be helpful
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

What kind is your application, winform or webform. If you are develop a winform application, then you cannot use paging.

If you are develop a webform, then set following property:

1. Right click on your data grid, select Property Builder
2. Select Paging from left panel, then tick Allow Paging.
3. Set Page size: to 50 rows
Mohammed NasmanSoftware DeveloperCommented:

  I prefer to limit the result on the server, because running query return 1 million records, and only show 50 record in client, will take the resource on the server

the best practile for this situation to limit the result from the query it self like

SELECT top 50 * FROM Products;

if your query result doesn't return much records, and you would to show them as pages

follow the dungla steps for adding the paging support to dataGrid, but you need to write code in PageIndexChanged event to show the right data when user move between pages

            private void Page_Load(object sender, System.EventArgs e)

            private void FillData()
                  DataGrid1.DataSource = ds.Tables[0];

            private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
                  DataGrid1.CurrentPageIndex = e.NewPageIndex;


cossy74Author Commented:
dungla: I have found the Fill method has an overload that takes a dataset, the starting record, number to return, and the table. This seems to be working for me.

using a dataadapter i do

I am going to split the points between everyone because althouhg i found the result myself i think you all should get somethign for helping.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.