I am studying LINQ recently. I think it is really very simple to see it on the page, but I am worried that I will mix up my knowledge when I learned it. I don't know if everyone is the same as me when I first learned it, because some of his landlords are really like SQL
Paging method:
Total number of retrieved data entries: var COUNT = dB. xxx. count (); if the previous statement has to write select count (*) from xxxx; you have to call sqlhelper. only the methods in the CS class can be used. Now we can do this in one sentence ...... Sweat ..
Use the SKIP () and take () methods for paging.
Reference to Li yongjing's blog
I want to learn how to blog with him: http://www.cnblogs.com/lyj/.
Note: Skip () skips the first n elements of the Set; delay. That is, we will skip the given number and return the result set.
Note: Take () gets the first n elements of the Set; delay. That is, only a limited number of result sets are returned.
Paste the code below
ASPX page code snippet: Only one gridview and one aspnetpager control, no other code;
<Div>
<Asp: gridview id = "gridview1" runat = "server">
</ASP: gridview>
<Webdiyer: aspnetpager id = "aspnetpager1" runat = "server" onpagechanged = "aspnetpager1_pagechanged"
Pagesize = "15" urlpaging = "true">
</Webdiyer: aspnetpager>
</Div>
Background code:
VaR COUNT = dB. inbill. Count ();
Aspnetpager1.recordcount = count;
VaR paging = (from I in db. inbill
Orderby I. indate descending
Select I). Skip (aspnetpager1.startrecordindex-1). Take (aspnetpager1.pagesize); // index method: Paging operation;
Gridview1.datasource = paging;
Gridview1.databind ();