O'Reilly logo

Applied ASP.NET 4 in Context by Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Quick Example of Using Data Source Controls

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.

Creating the Data

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

using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required