Page 164 - DCAP312_WEB_TECHNOLOGIES_II
P. 164
Web Technologies-II
Notes 8.3 Data Binding
Data binding is merely a program’s ability to bind some members of an aim module to the
members of a data source. We may use statistics binding to fill lists with selectable substance
from an imported data cause, like a database, an XML file, or a script.
The following controls are list controls which support data binding:
• asp: RadioButtonList
• asp: CheckBoxList
• asp: DropDownList
• asp: Listbox
The selectable items in each of the above controls are usually defined by one or more asp:ListItem
controls, like this:
<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, with data binding we may use a separate source, like a database, an XML file, or a
script to fill the list with selectable items.
By using an imported source, the data is separated from the HTML, and any changes to the
items are made in the separate data source.
8.3.1 RadioButtonList
The RadioButtonList control is used to create a group of radio buttons.
Each selectable item in a RadioButtonList control is defined by a ListItem element!
<script runat= “server”>
Sub submit(sender As Object, e As EventArgs)
label1.Text= “You selected “ & radiolist1.SelectedItem.Text
End Sub
</script>
<!DOCTYPE html>
<html>
<body>
<form runat= “server”>
158 LOVELY PROFESSIONAL UNIVERSITY