ASP. NET Web Data Control

Source: Internet
Author: User
1. Data Control Overview
This includes data source controls and format settings controls. The former allows you to use Web controls to access data in databases, and the latter allows you to display and operate data on ASP. NET web pages.
2. Data Control
* Gridview Control: Displays data in the form of tables, and provides the ability to sort columns, read data, and edit or delete a single record.
* Detailsview Control: Displays records in the form of a table at a time, and provides the ability to read multiple records and insert, update, and delete records. DetailsviewControls are usually used in the master/detail scheme. In this scheme GridviewThe selected records in DetailsviewControl display records.
* Formview Control: And DetailsviewSimilar to the control, it presents a record in the data source at a time and provides the ability to read multiple records and insert, update, and delete records. However, FormviewControls and DetailsviewThe difference between controls is: DetailsviewThe control uses a table-based layout. In this layout, each field of the data record is displayed as a row in the control. While FormviewThe control does not specify the predefined layout used to display records.
* Repeater control: Displays the read-only list using a set of records returned from the data source. And FormviewControls are similar, RepeaterThe widget does not specify the built-in layout. You can use the template to create RepeaterControl layout.
* Datalist Control: Displays data in the form of a table. With this control, you can use different la s to display data records, for example, arranging data records into columns or rows. You can DatalistAllows you to edit or delete records in a table. ( DatalistThe control does not use the data modification function of the data source control. You must provide this code by yourself .) DatalistControls and RepeaterControls differ in the following: DatalistControls explicitly place items in HTML tables, while RepeaterControl.
3. Data Control example
Example 1: gridview Control
Knowledge involved: Data Binding, sorting, paging, selected content, editing, deletion, and templates
Example 2: detailsview Control
Note:: Used in the previous section DetailsviewThe options used to enable editing, insertion, and deletion are unavailable. This is because DetailsviewThe "sqlperformance1" control to which the control is bound does not have the required SQL statement. The data source has been configured to include the update statement, so the update option is DetailsviewControls are available.
Note:: Exploitation DetailsviewControls and GridviewControls are combined to implement the master/detail page.
Select the "gridview" control and select "Edit column" from the "gridview task" menu ".
Under "available fields", open the "command field" node, select "select", and click "add" to add it.
In the "selected fields" list, select "select" and set the "selecttext" attribute in the "commandfield" attribute grid.
Set to "details ".
In the Properties window, confirm the setting of its datakeynames attribute.
Select detailsviewControl, set another data source because of its conditional query. This information is displayed based on the above selection.
Note:: Exploitation DetailsviewControls and GridviewControls are used to implement master/detail information for different pages.
The hyperlink is used to pass the value. Therefore, the homepage gridview control adds the hyperlink control, datanavigateurlfields, which indicates that the hyperlink should obtain its value from the ** column datanavigateurlformatstring: XX. aspx? Cid = {0} is the hardcoded link used to navigate to the XX. ASPX page. This link also transmits a query string variable named CID. The value of this variable is filled with columns referenced in the datanavigateurlfields attribute.
Example 3: formview Control
Note:: And DetailsviewControls: You can set the display layout and the layout for editing and inserting operations based on the specific data conditions.
Note:: Binding expression
<% # Eval ("field name") %>
<% # BIND ("field name") %>
Differences: Eval is read-only data, and bind is updatable. Eval one-way binding: data is read-only.
Bind two-way binding: the data can be changed and returned to the server. The server can process the changed data, such as storing it in the database.
Related Article

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.