[Reprinted] implement manual paging setting in gridview

Source: Internet
Author: User
First, set allowpaging = "true" in the property interface gridview" 1 Protected   Void Page_load ( Object Sender, eventargs E)
2 {
3 String Keyword = Request [ " Keyword " ];
4 Sqlconnection con = DB. createconnection ();
5 Con. open ();
6 Dataset DS =   New Dataset ();
7 Sqldataadapter SDR =   New Sqldataadapter ();
8 SDR. selectcommand =   New Sqlcommand ( " Select * From IPaddress where IP like '% "   + Keyword +   " %' " , Con );
9 SDR. Fill (DS );
10 Gridview1.datasource = DS;
11 DS. Dispose ();
12 Con. Close ();
13 Gridview1.databind ();
14
15 }
16
17 // Add a color to the row
18 Protected   Void Gridview1_rowcreated ( Object Sender, gridviewroweventargs E)
19 {
20 If (E. Row. rowtype = Datacontrolrowtype. datarow)
21 {
22 E. Row. Attributes. Add ( " Onmouseover " , " C = This. style. backgroundcolor; this. style. backgroundcolor = '# 3399ff '; " );
23 E. Row. Attributes. Add ( " Onmouseout " , " This. style. backgroundcolor = C; " );
24 }
25 }
26
27
28 // The gridview has a pageindexchanging event.
29 Protected   Void Gridview1_pageindexchanging ( Object Sender, gridviewpageeventargs E)
30 {
31This. Gridview1.pageindex=E. newpageindex;
32This. Gridview1.databind ();
33}
34

In this way, manual paging is displayed.
From: http://www.banysky.com/blog/article.asp? Id = 38

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.