Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

gridview paging and sorting winth LINQ

Posted on 2008-06-17
8
1,886 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

839 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