asp.net| paging ASP. NET paging components learning and using--using articles
Hello everyone, this article is the last article "ASP." NET pagination component learning and using--teaching article.
In the ASP. NET pagination component learning and using--teaching article, we explained the entire creation process of the paging component, so in this article, we discuss how to use the component.
Follow these steps:
1. Create a Web application project.
2, add the components generated in the previous article to the Toolbox. If you do not know the procedure to add, please refer to the article ASP. NET component programming Step by step
3. In the Default Web Forms page, switch to HTML view and copy the following HTML code into the <form> tab.
SqlConnection con = new SqlConnection ("Server=accp-lzh;uid=sa;pwd=sasa;database=northwind");
SqlCommand cmd = new SqlCommand ("SELECT * from [Order Details]", con);
SqlDataAdapter adapter = new SqlDataAdapter ();
Adapter. SelectCommand = cmd;
DataSet ds = new DataSet ();
Con. Open ();
Adapter. Fill (ds, "table");
Con. Close ();
DataTable dt = new DataTable ();
DT = ds. tables["Table"];
The following sets the control parameters
This. Lzhpages1.allcount = dt. rows.count;//Total Record Bar number
This. Lzhpages1.currentpage = cp;//The current page, read from the URL
This. Lzhpages1.showpages = number of 10;//navigation numbers
This. Lzhpages1.count = 10;//number of record bars displayed per page
StringBuilder sql = new StringBuilder ();
The following three strings are eventually combined into a complete table <table>
String htmlheader = "";//<table> label
String htmlBody = "";//There are a number of <tr> tags in the middle.
String htmlfoot = "";//</table> label
Sql. AppendFormat ("Select top {0} * from [order Details] where 1=1 and OrderID" (select top {1}) OrderID from [Order Detai LS] where 1=1 ORDER by OrderID Desc) ", and" by OrderID Desc. Lzhpages1.count,this. Lzhpages1.currentpage * this. Lzhpages1.count);
SqlCommand cmd1 = new SqlCommand (SQL. ToString (), con);
6, SQL. AppendFormat ("Select top {0} * from [order Details] where 1=1 and OrderID" (select top {1}) OrderID from [Order Detai LS] where 1=1 ORDER by OrderID Desc) ", and" by OrderID Desc. Lzhpages1.count,this. Lzhpages1.currentpage * this. LZHPAGES1.COUNT); The SQL statements in this statement are used for paging, our controls are used only to control the page, and the data is read through SQL statements or stored procedures.
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.