Normally, do not use the pagination that comes with the gridview, And the execution efficiency is not high. In particular, it takes a long time to load the page for massive data to be displayed. However, if we want to use the gridview to display data and improve the data paging performance, the following ASP. net2.0 massive storage process paging control can solve your problem.
ASP. the paging control of net2.0 massive storage process uses the Stored Procedure for paging to index the queried results based on the primary key or unique ID of the results. When paging, only the index is paged, without loading all the data to be displayed, the performance is greatly improved.
The following describes how to use the control:
1. PageCode
<% @ Register Assembly = "procdurepagernet2_0" namespace = "procdurepagernet2_0" tagprefix = "PC3" %>
<PC3: pager id = "pager1" runat = "server" oncommand = "pager_command" showfirstlast = "true"> </PC3: pager>
2. CS code
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Pager1.currentindex = 1;
Bindrepeateradvance (1 );
}
}
Public void pager_command (Object sender, commandeventargs E)
{
Int currnetpageindx = convert. toint32 (E. commandargument );
Pager1.currentindex = currnetpageindx;
Bindrepeateradvance (currnetpageindx );
}
Private void bindrepeateradvance (INT pageno)
{
Sqlconnection Cn = new sqlconnection (gloab. getconnstring ());
Sqlcommand cmd = new sqlcommand ("DBO. getpaged_news", CN );
Cmd. commandtype = commandtype. storedprocedure;
Sqldatareader Dr;
Cmd. Parameters. Add ("@ pagesize", sqldbtype. Int, 4). value = pager1.pagesize;
Cmd. Parameters. Add ("@ currentpage", sqldbtype. Int, 4). value = pageno;
Cmd. Parameters. Add ("@ itemcount", sqldbtype. INT). Direction = parameterdirection. output;
Sqlparameter fname_1 = cmd. Parameters. Add ("@ title", sqldbtype. nvarchar );
Fname_1.direction = parameterdirection. input;
Fname_1.value = txt_title.text.trim (); // display the query results based on the title
CN. open ();
Dr = cmd. executereader (commandbehavior. closeconnection );
Grid_news.datasource = Dr;
Grid_news.databind ();
Int32 _ totalrecords = convert. toint32 (CMD. Parameters ["@ itemcount"]. value );
Pager1.itemcount = _ totalrecords;
Dr. Close ();
CN. Close ();
Sqlconnection. clearpool (CN );
}
Demo address: http://www.mycjweb.com/CJSearch.aspx
Need complete source code and controls to send me an email: y.xwx@163.com