Solved

gridview paging and sorting winth LINQ

Posted on 2008-06-17
8
1,882 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
ID: 21805247
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
ID: 21836543
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
ID: 21889332
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Accepted Solution

by:
enrique_aeo earned 0 total points
ID: 21946812
0
 

Author Comment

by:enrique_aeo
ID: 22009619
ok
0
 
LVL 21

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

14 Experts available now in Live!

Get 1:1 Help Now