Data source controls: performancecontrol (2)

Source: Internet
Author: User

Http://www.manuelabadia.com/blog/PermaLink,guid,eb...

Previous Article: Data Souce controls: basedataboundcontrol and databoundcontrol (1)

In the previous articleArticle, I explained the basic structure of the data binding control (how to obtain data from performanceview when the Framework calls the binding method ). It is time to explain the performancecontrol class.

The good news is that I found a series of articles about data source controls in Nikhil Kothari, a member of the ASP. NET development group:
Http://www.nikhilk.net/DataSourceControlBasics.aspx
Http://www.nikhilk.net/DataSourceControlParameters.aspx
Http://www.nikhilk.net/DataSourceControlsAsync.aspx
Http://www.nikhilk.net/DataSourceControlsCache.aspx
Http://www.nikhilk.net/DataSourceControlsDesignTime.aspx

If you have not read ASP. NET Server Control and component development, read it.

If you want to use the new data binding mechanism on the data binding control, you must have a data source that implements self-idatasource, or use a data source control that comes with ASP. net2.0 (sqldatasource and objectdatasource)

To implement custom data sources, you can inherit from performancecontrol, because this class can be implemented more easily. The datasource control inherits from the control class and implements the idatasouce and ilistsource interfaces. Let's study these interfaces to see how to implement them from performancecontrol.

The idatasouce interface is very simple. It only has the following public methods:

Performanceview getview (string viewname );

Icollection getviewnames ();

The first method is to bind a specific view, and the second method is to obtain the number of exposed performanceviews and their names. The data source control (sqldatasource and objectdatasoucr) has only one view. However, you can use multiple views to expose some data in the data source. This method is more useful than using a single view.
If you have read my previous article, there is a method for the data binding control to call connecttodatasouceview, this method attempts to find a view in the data source (it is easy to complete in the idatasource interface ). However, to support the original binding structure, a data source control also has a datasource attribute, which can be set to an object not implemented from idatasouce, to be complete, the databoundcontrol class has a read-only performancecontrol encapsulation. In this scenario, it exposes data as read-only datasouceview.

The idatasource interface also exposes a public method.
Event eventhandler performancechanged;

As I have explained in my previous articles, when a data source control is bound to a data source control, the data source control will capture a datasouceviewchanged event of performanceview. When the data source changes, this time is also triggered and the data binding control calls the databind method to refresh the data. If the data source control changes, the datasoucechanged event will be triggered, and all performanceviews will capture and update their own data (execute this event in the performanceview class and trigger the performanceviewchanged event ).

Datasoucecontrol implements the idatasouce interface, but does not implement it, because it calls the protection methods getview and getviewnames to be implemented in its subclass.

The ilistsource interface enables an object to return a list, which can be bound to a data source. Why do we have the data source control implement ilistsource? This is to bind a data source control to the datasource property of the data binding control. The data binding control is not inherited from baseboundcontrol, such as the DataGrid.

Datasoucecontrol implements the ilistsouce interface to conveniently call the listsourcehelper class. This class exposes a View list (datasouceviews) to bind (this is similar to the many datatables in dataset ). This view List implements the itypelist interface to expose the schema for binding. I don't want to detail the family's less itypelist, but if you are interested in this, you can refer to the following link.

Http://weblogs.asp.net/fbouma/articles/115837.aspx

To put it short, the datasourcecontrol implemented from ilistsource exposes the View list. Each view is displayed as a read-only attribute of the ienumerable type and its value is returned in the executeselect method of the view.

Datasoucecontrol has some hidden attributes during design. Although datasoucecontrol inherits from control, it is not a visualized control, nor is it component because it is in ASP. invalid in net2.0.

These are the datasoucecontrol classes. Soon we will talk about performanceview, which is actually a class for data binding.

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.