DOTNET front-end page and data table regular Binding Mechanism Analysis

Source: Internet
Author: User

Make a memo for future development of dynamic pages.

Objectdatasource)
Business Object Name and data object name to be bound

    • The business object is actually a class object that contains the specific operation methods of the data table. Most of these methods include data objects as parameters for transmission.
    • A data object contains a set of attributes of the same name as a data table field, used to pass values between the page and the database.

The data source can use four main data table operation method names (select, update, insert, delete). These methods are included in the business object, and the data source can also define other event names, all event methods are in the background file.

Formview is a view with the data submission function. It is an encapsulation of form labels on HTML pages. It mainly provides creation and maintenance, and can contain four templates: Edit, insert, item, and empty, the formview page is displayed in different statuses using different templates. After a data source is specified, formview is associated with objectdatasource so that different templates are automatically bound to the corresponding methods of the data source.

    • The Edit template is used for data maintenance during update, including related controls, including the SAVE and cancel buttons. Existing records are specified by using the gridview or other methods, after switching to the edit template, the Select method of the data source is automatically executed. After obtaining the data object, bind the control in the template to display the record value. After you modify the data, click Save to execute the data source update method.
    • The insert template is used to create record data input, including related controls, including the insert and cancel buttons. After switching, all controls are initialized. After the data input is complete, click the insert button to execute the insert method of the data source.
    • The item template is used to display the data of a specified record. It is generally null and contains a new button. It is used to switch to the insert template and run select to display the record content.
    • The empty template is used on the interface when no record is specified. It is generally blank and contains a new button to switch to the insert template.

In formview, all templates with data tables to write must contain controls consistent with the data object and bind relevant properties of the data object,
If some data does not need to be rendered, you must bind the property with a hidden control (hidden) because the binding mechanism of. NET must be bound to all the attributes of the data object; otherwise, an error occurs.
When binding data, you can use macro-like function intervention to bind data to meet different requirements, such as formatting the date display.

CodeExample (controls are bound to Data Object Attributes)
Value = '<% # BIND ("startdate") %>' bidirectional binding, which can be understood as read/write
Value = '<% # eval ("startdate") %>' display binding, which can be understood as read-only
TEXT = '<% # obj. Format (eval ("startdate") %>' format after date display is bound
TEXT = '<% # Wai. getgroupname (eval ("deptcode") display after binding

As you can see from the example, the front-end display BIND uses background objects and methods for processing.

In most data systems, operations related to databases are similar to the insert (new), update (maintenance), delete, and query of records. From a functional perspective, in addition to querying, other operations can only be used as data maintenance, and can only be authorized to data maintenance personnel, while querying

Pages are generally used to query, view, and collect statistics for general users.

The binding mechanism of the gridview is similar to that of the formview.

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.