You need three items to work with the Web Forms data controls: some data, a data source control, and a data-bound UI control.
To begin, create a new Visual Studio project named
WebApp using the Empty ASP.NET Application template and add a new Web Form called
Default.aspx. All of the examples in this chapter will be added to this page.
You can use a range of different data types with Web Forms, but we are going to start with the simplest—some objects contained in a class. In the code-behind file,
Default.aspx.cs, define a new data type called
Fruit and create an array of
Fruit objects in the
Default code-behind class, as shown in Listing 18-1.
Listing 18-1. Creating some data