Massive storage process paging control ASP. net2.0

Source: Internet
Author: User

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

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.