Asp. NET: Getting Started with database bonding controls

Source: Internet
Author: User
Tags net
asp.net| Controls | data | database-bound controls are part of a Web control, but they are especially important because they are tightly integrated with the database and are widely used in Web applications. In this chapter, we will describe in detail the use of data-bound controls in ASP.net technology.

9.1 Database State Control Primer

In the last chapter of our study, we came across the DataGrid control, where we used DataAdapter to read data from the database, store it in a dataset, and then bind it to the DataGrid control, which is displayed by the DataGrid control. Data-bound controls can be used to quickly display formats for displaying a variety of settings. In ASP.net, there are three major data-bound control Repeater,datalist,datagrid available to users, which we'll learn in a later section.

9.1.1 <%#%> Grammar

ASP.net introduces a new declarative syntax <%#%>. This syntax is the basis for using data binding in an. aspx page. All data-binding expressions must be contained in these characters. The following list contains examples of simple data binding from multiple sources:

(1) Data binding for a simple property (for the client's syntax):
<%# CustID%>

(2) Data binding for a set dataset (syntax for orders):
<asp:listbox id= "Lst1" datasource= ' <%# myarray '%> ' server ' runat=

(3) The data binding of an expression (for the contact's syntax):
<%# (Customer. The Name + "" + customer. LastName)%>

(4) Data binding for the result of the method (syntax for outstanding balances):
<%# getbalance (CustID)%>

(5) Data binding for ordinary Web controls:
<asp:textbox id=txt text= "<%# custid%>" Runat=server/>
<%#%> syntax is generally used in a comprehensive, in the next section, we will practice the application of the syntax in the program with an example.



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.