Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi.

I have a MVC project with a form and a submit button.
The values are passed to the controller. One method will fetch data from the dataset according to the parameters passed. Then some VB functions will work with the data retrieved.
Currently I have the whole dataset being filled after the ajax.

My problem is the db is very big and it takes more time to get the results than I wish to.

I tried to fill the dataset at windows.onload puting a specific function just for that in the same controller but that way when the ajax call is made there's no dataset filled.

Is this possible and I just need to do it the right way or it has to fill after the ajax call?

Thanks
Posted

As you said,
Quote:
db is very big and it takes more time to get the results

So it seems you are fetching much more data, that what you can show on the screen at page load.

In this case it seems, pagination will help. So initially make a query to get only the data (or little more) which webpage can show to user and then incrementally you can load more data while user clicks on a particular page number. Accordingly you need to optimize query to database too.

There are many samples available for pagination in ASP.NET MVC. I am not sure whether you are using Entity framework or ADO.NET in your project, please search for appropriate code samples.

For quick idea of pagination, have a look on:
http://devproconnections.com/aspnet-mvc/aspnet-mvc-paging-done-perfectly[^]

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application[^]

http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/[^]

For more optimization, use caching in ASP.NET MVC for first few rows of data ....and at database side, use indexing on appropriate columns.

You further queries are most welcome.
 
Share this answer
 
v4
i'm dumb! I just need to only fill with the data I need.
 
Share this answer
 

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