Keywords:Downmoon, C #, paging(Source code is provided below)
Common ASP. NET data paging controls
For almost all data presentation web applications, organizing the data display mode to avoid confusion is the most important
One of the goals. It is acceptable to display 20 records on each page, but 10000 records on each page can easily cause inconvenience to users. Divide the data into multiple pages for display, that is, divide the data
Page is the most common solution to this problem.
I. Statement
ASP. NET provides only one control that supports data paging, that is
The DataGrid paging control, but it is suitable for the Intranet environment. For the Internet environment, the functions provided by the DataGrid paging control do not seem sufficient to be constructed.
Provides flexible web applications. One of the reasons is that the DataGrid Control has restrictions on the location where the web designer places the paging control and the appearance of the paging control. For example, the DataGrid control does not allow
Vertical paging control. Another control that can take advantage of paging technology is repeater. Web developers can use the Repeater control to quickly configure the data display mode.
But developers need to implement it themselves. The data sources are constantly changing, and the data presentation methods are also very different. If you customize the paging controls for these constantly changing conditions, it is obviously a waste of time to construct
The general paging Control for specific display controls can greatly save time.
An excellent universal data control not only provides regular paging functions, but also provides the following features:
(1) provides "Homepage", "Previous Page", "Next page", and "last page" navigation buttons.
(2)
You can adjust your own status based on the data display, that is, data sensitivity. If the paging control is set to display 10 records per page, but there are actually only 9 records, the paging control should not be displayed;
When data is divided into multiple pages, the "Homepage" and "Previous Page" buttons on the first page should not be displayed, the "next page" and "last page" buttons on the last page should not be displayed.
(3) You cannot rely on specific data display controls.
(4) ability to adapt to various existing data sources.
The consumer should be able to easily configure the display mode and easily integrate it into various applications.
When the page is ready, other controls are reminded.
Even inexperienced web designers, idea must be able to use it without any difficulty.
⑻ Provides attribute data about paging information.
Currently, there are some commercial controls that provide the above functions on the market, but they are expensive. For many developers, constructing a universal paging control is the best choice.
Figure 1 shows the running interface of the general paging control in this article. The control used for display is a repeater control. The paging control consists of two components: four navigation buttons and a group of page numbers.
You can easily change the display controls and the appearance of the paging controls. For example, in Figure 1, a display control that works with a paging control can be sent to a DataGrid Control. The page number link and the four navigation buttons are displayed in two lines.
ASP. NET
You can create custom Web controls in three ways: User Controls, composite controls, and custom controls. The third type of control is that the name of the custom control is easy to misunderstand. In fact, all these three controls are
Define controls. The difference between a composite control and a custom control called by Microsoft is that the former uses the createchildcontrols () method,
The createchildcontrols () method allows the control to redraw itself based on certain events. For the general page splitter in this article, we will use the composite control.
The following UML sequence diagram summarizes the general mechanism of general paging controls.
Although
However, our goal is to make the general paging control independent from the control that represents data, but obviously, there must be some way for the paging control to access data. Each control inherited from the control class provides
Databinding event. We register the page sharer as the listener of the databinding event, so that the page sharer can know the data and modify the data. Because all slave
The controls inherited by the control class all have this databinding event, so the page sharer control achieves the goal of not relying on specific data presentation controls-in other words, the page sharer control can be bound
To all controls derived from the control class, that is, it can be bound to almost all Web controls.