While some of the content in a web application may be fixed, any interesting website will change over time. So it’s highly likely that you’ll want some of the controls on your web page to display data that can change from time to time, and which is probably stored in a database. Many ASP.NET controls can be data-bound, which simplifies display and modification of data.
In the preceding section we hardcoded radio buttons onto a form—one for each of three shippers.
That can’t be the best way to do it—relationships with suppliers change,
and there’s a good chance that we may want to work with different shippers
in the future. We don’t really want to have to go back and rewire the
controls each time that kind of business relationship changes. It makes
more sense to store the list of shippers in a database, and have the UI
reflect that. (In fact, if you’re familiar with Microsoft’s sample
databases, you may recognize the three shippers in the earlier examples as
the ones provided in the “Northwind” sample database.) This section shows
you how you can create these controls dynamically and then bind them to
data in the database, by using the
RadioButtonList control’s data binding
Add a new web form called DisplayShippers.aspx to your project. Put the
editor into Split mode. From the toolbox, drag a
RadioButtonList onto the new form, either onto
the design pane or within the
<div> in the Source view.
If you don’t see the radio buttons on the left of your work space, ...