Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

gridview paging and sorting winth LINQ

Posted on 2008-06-17
8
Medium Priority
?
1,897 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

927 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