Add home, last page, and status features for the DataGrid's own pagination
Source: Internet
Author: User
The datagrid| paging DataGrid provides paging functionality, but it seems to be limited, but we can get the status through some of the DataGrid's properties and add the Home page, last feature button. There is no custom paging feature for the DataGrid, and it's good to manage paging by the DataGrid if it's not very efficient in the case of speed efficiency, and the cost is to get the whole data out and then delete the data from the specified page. The advantage is that the development speed is fast, do not need to write paging stored procedures. The example in this article uses the Northwind database in SQL Server. The running interface is as follows:
For the foreground display interface, I put a DataGrid, four LinkButton buttons, and four literal to display the record status.
The rest is to use the table to locate.
You need to set the AllowPaging property of the DataGrid to True and set the AllowCustomPaging property bit False (the default is False), and set the Visible property of PagerStyle to False so that the foreground does not appear.
<asp:literal id= "Ltlpageindex" runat= "Server" ></asp:literal> page total
<asp:literal id= "Ltlpagecount" runat= "Server" ></asp:literal> page per page
<asp:literal id= "ltlpagesize" runat= "Server" ></asp:literal> strip total
<asp:literal id= "Ltlrecordcount" runat= "Server" ></asp:literal> Bar
</TD>
</TR>
</TABLE>
</form>
</body>
</HTML>
Background CS file code, datagridpaging class from the System.Web.UI.Page inheritance, in the data binding time to pay attention to the situation without data (0 pages), and when the number of pages to avoid the foreground is reverse page caused by pages.
It is recommended that you use the custom paging feature of the DataGrid if you need to pursue execution efficiencies and have a large amount of data. The stored procedure executes only one page. If you have any good suggestions or find problems, please leave a message on the blog.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service