Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a listview with datapager with page size 10 in which i list data from DB.I have noticed when using data pager entire result from the table are taken by query and it slow downs the system.How can i achieve to get only first 10 result from db and then using paging next 10 results etc.Please help
Posted
Comments
[no name] 7-Oct-14 8:17am    
You write a query to get the first 10 based on whatever criteria you have available in your database, then you would query the next 10 based on the same criteria, etc.
Namith Krishnan E 7-Oct-14 8:20am    
then how can i create paging?
[no name] 7-Oct-14 8:49am    
What does that have to do with your question? You already have paging you just didn't like it for some reason.
Namith Krishnan E 9-Oct-14 3:01am    
i have paging and working file.But the problem is with the performance.when the listview loads it takes a lot of time because of large amount of data.when using data pager it takes all the result from table and display first 10 instead of this i only want first 10 result totake from db
Richard Deeming 7-Oct-14 8:29am    
Are you using the <asp:SqlDataSource> control to bind your data? That control doesn't support paging. You'll need to use an <ObjectDataSource>, an <EntityFrameworkDataSource>, or ASP.NET 4.5's model binding.

Hey , you can take a look at
Effective paging with List View control in ASP.NET[^]
this article may help you.
 
Share this answer
 
Comments
Namith Krishnan E 9-Oct-14 3:12am    
By looking at this code i think this one iam looking for

5*
To get only first 6 records use the top-n analysis query.

SELECT TOP 6 column FROM tablename
 
Share this answer
 
Comments
Namith Krishnan E 9-Oct-14 3:02am    
i want paging too,if i take top 6 i didnt get the next results in paging
MukeshSagar 9-Oct-14 3:14am    
Use the PageIndexChanged event and rebind the control

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900