ASP.NET - Data Binding

« Previous Chapter Next Chapter »

We may use data binding to fill lists with selectable items from an imported data source, like a database, an XML file, or a script.

Data Binding

The Below 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="playerlist" runat="server">
<asp:ListItem value="N" text="Sachin" />
<asp:ListItem value="S" text="Pointing" />
<asp:ListItem value="F" text="Nadal" />
<asp:ListItem value="I" text="Saina" />
</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.

In the next three chapters, we will describe how to bind data from a scripted data source.


« Previous Chapter Next Chapter »

Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!