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