Solved

gridview paging and sorting winth LINQ

Posted on 2008-06-17
8
1,878 Views
Last Modified: 2013-12-16
I need pages OR CODE  where they give detail the use of paging and sorting of a gridview control.
--web application:
gvListaMrp.DataSource = olista.ListarMrp(centroId, materialId, grupoArticulo, unidadNegocio, tipoMaterial, costoEstandar, costoVariable);
            gvListaMrp.DataBind();
--layer datacces:
var query = dt.uspListarMrp(centroId, materialId, grupoArticulo, unidadNegocio, tipoMaterial, Convert.ToDecimal(costoEstandar), Convert.ToDecimal(costoVariable));
                        foreach (var i in query)
                        {
                            resultado.Add(new ListaMrp()
                            {
                                CentroId = i.CentroId.Trim(),
                                MaterialId = i.MaterialId.Trim(),
                                DescripcionMaterial = i.DescripcionMaterial.Trim().ToUpper()
                            });
                        }
0
Comment
Question by:enrique_aeo
  • 3
  • 3
8 Comments
 
LVL 21

Expert Comment

by:naspinski
Comment Utility
This video here shows a great usage of paging:
http://weblogs.asp.net/scottgu/archive/2007/01/28/video-using-linq-with-asp-net-in-vs-orcas-part-1.aspx

I will also take another look at your question when I get up tomorrow morning.
0
 
LVL 21

Expert Comment

by:naspinski
Comment Utility
Using the someQuery.Take(number_of_records_per_page) is a great way to implement paging - drastically lowering your sql traffic.

For example, query.take(10) actually queries ONYL the first 10 items in that list, not querying them all and returning just the first 10.  Thisi can be very important with huge data sets.

To get to a later area in the paging, you just incorporate the Skip method:
query.Skip(100).Take(10) will skip 100 records and take 101-110, once again querying only those 10 records.  Very efficient.

something to keep in mind that will be useful for paging is:
query.Skip(0).Take(number) is the same as query.Take(number)
0
 

Author Comment

by:enrique_aeo
Comment Utility
Hi, this very interesting paginacion optimized that you propose, but do not understand my well, you may get an example with the code that I have put lines above. I'm start with linq
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Accepted Solution

by:
enrique_aeo earned 0 total points
Comment Utility
0
 

Author Comment

by:enrique_aeo
Comment Utility
ok
0
 
LVL 21

Expert Comment

by:naspinski
Comment Utility
not to be picky, but isn't that exactly what I was saying?
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now