Datasets and paging

Hi
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
cossy74Asked:
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
dunglaCommented:
cossy74,

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
0
Mohammed NasmanSoftware DeveloperCommented:
Hello

  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)
            {
                  FillData();
            }

            private void FillData()
            {
                  da.Fill(ds,"Products");
                  DataGrid1.DataSource = ds.Tables[0];
                  DataGrid1.DataBind();
            }

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


HTH

Regards,
Mohammed
0
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
Fill(dataset,recordnumber,pagelimit,table)

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.
0
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
C#

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.