ASP.NET Web Forms - Data Binding
This section describes how to implement data binding in ASP.NET.
We can use Data Binding to complete lists with options that come from an imported data source, such as a database, XML file, or script.
The following controls are list controls that support data binding:
asp:RadioButtonList
asp:CheckBoxList
asp:DropDownList
asp:Listbox
The options for each of the above controls are usually defined in one or more asp:ListItem controls, as follows:
<html><body><form runat="server"><asp:RadioButtonList id="countrylist" runat="server"><asp:ListItem value="N" text="Norway" /><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 data source for data binding, such as a database, XML file, or script, to populate the list of options through data binding.
By using an imported data source, the data is separated from the HTML, and modifications to the options are done in the independent data source.
In the next three chapters, we describe how to bind data from scripted data sources.