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.