Recently, a project requires a display control with the paging function. The gridview control is powerless because of the large data volume. Therefore, I wrote a page display control gridtable that supports a large amount of data (of course, the massive data query algorithm needs to be done by myself). The control inherits repeater.
The data source of the control does not use datasource to assign values. Instead, it implements an internal delegate "objectperformancebindeventhandler (INT startcount, int endcount)". This method defines two variables: the start row number and the end row number of the result set, returns a result set object to implement the paging function. The effect is as follows:
Part of the aspx File Code
Aspx code <Wc1: gridtable id = "grid1" runat = "server" bannertextformat = "{0} per page/{1} in total & nbsp; page {2}/{3} in total"
Pagesize = "5" bannercls = "bannercls" pagerposition = "both" paginationcls = "pagind"
Pageimgbturl = "btn4.gif" allowpaging = "true">
<Pagetemplate>
<H1>
Pagetemplate show </Pagetemplate>
<Headertemplate>
<DL class = "briefresult">
</Headertemplate>
<Itemtemplate>
<DT>
<a href = "#"> <% # eval ("name ") %> </a>
<Span> Health Preserving Yangsheng </span> </DT>
<DD>
<% # Eval ("info") %>
</DD>
<Dd class = "more">
<A href = "#"> read the full text >></A> </DD>
</Itemtemplate>
<Footertemplate>
</Dl> </footertemplate>
<Emptydatatemplate>
<H1>
Emptydata </Emptydatatemplate>
</Wc1: gridtable>
Backend. CS
. CS code Protected void page_load (Object sender, eventargs E)
{
Grid1.objectperformancebind + = new TPI. Web. UI. webcontrols. gridtable. objectperformancebindeventhandler (grid=objectperformancebind );
If (! Ispostback)
{
Grid1.databind ();
}
}
Object grid1_objectperformancebind (INT startcount, int endcount)
{
......
Return DT;
}
Insufficient
1. Because the repeater is inherited, all styles must be defined by themselves (it is troublesome to create tables)
2. There is no Ajax method to flip the page (I hope the experts will give you some advice on how to implement it without using updatepannel)
3. Simple functions, which need further improvement
You are welcome to publish the Code. If you have any good suggestions, please kindly advise me.
Source code download