how to get the Records (10 Pages datagrid paging) out of 50,000 Records.

  • Thread starter Thread starter karunakar rao
  • Start date Start date
K

karunakar rao

Hi All

I need some help. I have been populated 50,000 Records in asp.net C#
datagrid. Ever page has 10 records

Example "<< Prev 1 2 3 4 5 6 7 8 9 10 Next>> Iam showing like that in my
datagrid

When ever click the Next Buttuon Iam getting data from database
Total(50,000) Records.Every time performanse wise it is taken lot of
time

I need When ever click the Next Button that time i need only 11........
20 pages need to be get from database
Every need to get only 10 pages Not (50,000 Records.)

Some where i seen when ever click the Next that time store the temprary
table in database values and get into the that database.

Please help me any link is there please forward to me

Thank you,

Karunakara Rao. P
(e-mail address removed)
 
KRP,
unless you are using a custom paging solution that actually pages the
results in SQL Server using a cursor , table variable or similar mechanism
based on the starting and ending row numbers, you are getting all 50,000 rows
each time you page. 50,000 rows is just total overkill for a datagrid -
that's 500 pages!

So, you need to either refactor your solution to be looking for some sort of
reduced rowset based on some logical filter criteria, or else implement a SQL
- based paging solution that only returns the actual number of rows for the
specified page.
That's beyond the scope of a newsgroup post, but if you search around I am
sure you can find at least 2 or 3 examples of how to do this with Sql Server.
 
Hi,

Your solution should be in the SP that gets the records, you should be able
to get the next|prev page from the DB , and only those records.

you can do this in different ways, IIRC there was an article about this in
msdn magazine a few numbers back, try to google it, if not I can send you
the code I use for the same thing ( I cannot connect to my house computer
now :( )

cheers,
 
so in order from simple to complex - some options:

as Peter mentioned, showing the user a textbox to let them enter a
search term before they press 'search' is a good idea - parameterize
your stored procedure - add a where clause

a simple and quick option is to limit the number of returned records -
methods differ but if you're using SQL server, you can simply say
"select top 200 <fields> from <table>" - to give yourself a manageable
size and then just stick with what you have working now.

if you want to try the database driven paging - here's an example from
MSDN that discusses using the database to support your paging:

http://support.microsoft.com/default.aspx?scid=kb;en-us;829142

the problem there is that you'll have to implement a custom paging
solution - your next button will have to be 'smart' enough to send the
nextpage routine the last record ID that you pulled back. similarly,
your 'previous' button has to know the first record ID and send that.

one more thing to consider is whether to enable viewstate on the grid -
you get a lot of overhead on your transmissions when you send down the
viewstate. if you're going to create a custom paging solution that
includes the database, you might be better off not sending down the
viewstate and save yourself some time.

hope that helps,

g
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top