Use of the AspNetPager and My97DatePicker date controls

Source: Internet
Author: User

I have heard that the AspNetPager page control is powerful and never used it. I tried it yesterday and shared it with you today.

In fact, the home page for using this control has been described in detail, but I don't know if you feel like this, the more powerful the function is, the more complicated it is. For new users, the more difficult it is to find the place to start. I started to read the tutorial and found that there are actually just a few steps. For those who just want to use it without going into it, there is no need to understand the many documents at all. I will share with you the process of using the AspNetPager paging control quickly. For those who want to know more about the AspNetPager paging control, you can visit the home page of instructor Yang Tao.

The first step is to download the control first. Extract the AspNetPager. dll and AspNetPager. xml files;

Step 2: Add and reference this AspNetPager. dll in your project;

Step 3: register the control on the page

[Html]
<% @ Register Assembly = "AspNetPager" Namespace = "Wuqi. Webdiyer" TagPrefix = "webdiyer" %>
Step 4: Add a DataList control named DataListArticleList to the AspNetPager page control at a proper position on the page (for example, under the DataList Control, I have a DataList control on the page). The control name is Anpage.

[Html]
<Webdiyer: AspNetPager ID = "Anpage" runat = "server" CssClass = "paginator"
CurrentPageButtonClass = "cpb" FirstPageText = "Homepage" LastPageText = "last page"
NextPageText = "next page" PrevPageText = "Previous Page" OnPageChanged = "Anpage_PageChanged"
PageSize = "15" PageIndexBoxType = "TextBox">
</Webdiyer: AspNetPager>
Step 5: Data Binding: write data binding code on the page. cs

[Html]
Public void databind (string uid)
{
String SQL = "select * from Article where UserID =" + uid + "order by posttime desc ";
Opertbind (SQL );
}
 
Public void opertbind (string SQL)
{
SqlConnection cn = new SqlConnection (System. Configuration. ConfigurationManager. etettings ["ConnectionString"]. ToString ());
SqlDataAdapter da = new SqlDataAdapter (SQL, cn );
DataSet ds = new DataSet ();
Da. fill (ds, (Anpage. currentPageIndex-1) * Anpage. pageSize, Anpage. pageSize, "table"); // The Starting number of records. The number of records and table names are displayed on each page.
 
DataListArticleList. DataSource = ds;
DataListArticleList. DataBind ();
 
Anpage. RecordCount = countRecords (SQL); // The total number of records
}
 
Public int countRecords (string SQL)
{
Return Sqlbase. ExecuteTable (CommandType. Text, SQL, null). Rows. Count;
}
 
Protected void Anpage_PageChanged (object sender, EventArgs e)
{
Databind (ViewState ["id"]. ToString (); // rebind data after turning pages
}
 

This section also describes how to use the My97DatePicker date control.

First, download the control and decompress it to get a folder such as My97DatePicker;

Copy the folder to a project folder, such as the JS folder in the project root directory;

Then add the control to the page (between

[Html]
<Script language = "javascript" type = "text/javascript" src = "../JS/My97DatePicker/WdatePicker. js"> </script>
Then use this control. For example, if a TextBox obtains the focus, the control is loaded:

[Html]
<Asp: TextBox ID = "txtstartTime" runat = "server" Width = "200px" onfocus = "WdatePicker ({dateFmt: 'yyyy-M-d H: m: s '}) "> </asp: TextBox>
The final page. cs file gets the TextBox value:

[Html]
DateTime starttimestamps datetime.parse(this.txt startTime. Text );

Author: wangqiuyun
 

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.