Solved

gridview paging and sorting winth LINQ

Posted on 2008-06-17
8
1,887 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
[X]
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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 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