Users can easily change the display control and alter the appearance of the paging control itself. For example, in figure I, display controls that collaborate with pagination controls can be replaced with a DataGrid control, with page numbering links and four navigation buttons displayed in two rows.
ASP.net supports three ways to create custom Web controls: User controls, composite controls, and custom controls. The third type of control, the name of the custom control, can easily be misunderstood. In fact, all three of these controls should be considered custom controls. The difference between a composite control and Microsoft's so-called custom control is that the former uses the CreateChildControls () method, and the CreateChildControls () method allows the control to redraw itself based on certain events. For the general pager in this article, we'll use the composite control.
The following UML sequence diagram outlines the general mechanism of a common paging control.
While our goal is to make the universal paging control independent of the controls that represent the data, it is clear that there must be some way for the paging control to access the data. Each control that inherits from the controls class provides a DataBinding event. We register the pager itself as the listener for the DataBinding event, and the pager can learn the data and modify the data. Because all controls inherited from the control class have this databinding event, the pager control achieves the goal of not relying on a particular data representation control--in other words, the pager control can bind to all controls derived from the control class. That is, it can bind to almost all Web controls.