ASP.NET - Data Binding
- Previous Page WebForms Button
- Next Page WebForms ArrayList
We can use data binding (Data Binding) to complete a list with optional items, which come from some imported data source, such as a database, XML file, or script.
Data Binding
The following controls are list controls that support data binding:
- asp:RadioButtonList
- asp:CheckBoxList
- asp:DropDownList
- asp:Listbox
The optional items defined in each control above are usually defined in one or more asp:ListItem controls, similar to this:
<html> <body> <form runat="server"> <asp:RadioButtonList id="countrylist" runat="server"> <asp:ListItem value="C" text="China" /> <asp:ListItem value="S" text="Sweden" /> <asp:ListItem value="F" text="France" /> <asp:ListItem value="I" text="Italy" /> </asp:RadioButtonList> </form> </body> </html>
However, we can use some independent source for data binding, such as a database, XML file, or script to complete a list with optional items.
By using the imported source, the data is separated from HTML, and any changes to the project are completed in an independent data source.
In the following three sections, we will describe how to bind data from a scriptable data source.
- Previous Page WebForms Button
- Next Page WebForms ArrayList