The customer requested that all the queries be paged. every page is annoying. just want to make the DataGrid a separate control. after the query is completed on each page, use the displayed control. the idea is very clear, the speed is complete, debugging, error, the original damn paging control has to execute a query again! This public control cannot always perform queries on the query page one by one. Do you think you can make a notification? So you can add the event and debug it successfully.
Code:
Private void page_load (Object sender, system. eventargs E)
{
// Place user code here to initialize the page
Dgpagingcontrol1.equery + = new queryhandle (dgctrol1_q );
}
Protected ztemas. mastat. Web. mastatapp. usercontrol. dgpagingcontrol dgpagingcontrol1;
/// <Summary>
/// Method Name: dgctrol1_q
/// Content summary: rebind data
/// </Summary>
Private void dgctrol1_q ()
{
Dgpagingcontrol1.dgdatabind (query ());
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. btninquery. Click + = new system. eventhandler (this. btninquery_click );
This. btnreset. Click + = new system. eventhandler (this. btnreset_click );
This. Load + = new system. eventhandler (this. page_load );
}
# Endregion
/// <Summary>
/// Method Name: btninquery_click
/// Content summary: When the query button is clicked, call the corresponding method in the business logic component to obtain
/// Mastatreport object (Unified mobile phone file report entity), and
/// Bind
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private void btninquery_click (Object sender, system. eventargs E)
{
Dgpagingcontrol1.dgdatabind (query ());
// Display reports (this method is defined in the base class)
// Bindreport (mastatreport, datagrid1, true );
// Bind the paging Control Data
// This. dgtbind (mastatreport. datatable );
}
/// <Summary>
/// Method Name: Query
/// Content summary: Query, return mastatreport
/// </Summary>
/// <Returns> </returns>
Private datatable query ()
{......
}
In common
Public Delegate void queryhandle ();
/// <Summary>
/// Class ID: m09_dgpagingcontrol
/// Class Name: dgpagingcontrol
/// Content summary: Paging Control
/// </Summary>
Public class dgpagingcontrol: system. Web. UI. usercontrol
{
Protected system. Web. UI. webcontrols. DataGrid datagrid1;
Protected ZTE. itlib. Web. customcontrol. dbgnavigator dbgnavigator1;
Public event queryhandle equery;
/// <Summary>
/// Method Name: onquery
/// Content summary: Define a query event
/// </Summary>
Public void onquery ()
{
If (equery! = NULL)
Equery ();
}
Private mastatreport;
Private void page_load (Object sender, system. eventargs E)
{
// Place user code here to initialize the page
}
# code generated by region web forms designer
override protected void oninit (eventargs e)
{< br> //
// codegen: this call is ASP.. NET web form designer.
//
initializecomponent ();
base. oninit (E );
}< br>
//
// The method required by the designer. Do not use the code editor.
// modify the content of this method.
//
private void initializecomponent ()
{< br> This. dbgnavigator1.pageindexchanged + = new ZTE. itlib. web. customcontrol. dbgnavigator. pagechangedeventhandler (this. dbgnavigator1_pageindexchanged);
This. datagrid1.itemdatabound + = new system. web. UI. webcontrols. datagriditemeventhandler (this. maid);
This. load + = new system. eventhandler (this. page_load);
}
# Endregion
/// <Summary>
/// Method Name: dgpackagedatabind
/// Content summary: Data Binding
/// </Summary>
/// <Param name = "mastatreport"> </param>
Public void dgdatabind (datatable mastatreport)
{
// Use the dbgnavigator control to implement Paging for Data
Bindreport (mastatreport, datagrid1, true );
This. mastatreport = mastatreport;
This. dbgnavigator1.controldatasource =. datatable. defaultview;
This. dbgnavigator1.controltopaginate = This. datagrid1.uniqueid;
This. dbgnavigator1.databind ();
}
// This event is not added during the day, which may be Guan Jian
private void dbgnavigator1_indexchange (Object sender, system. eventargs e)
{< br> // place the user code here to initialize the page
onquery;
}