O'Reilly logo

ASP.NET by Example by Steven A. Smith

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

Data Controls

We've seen that ADO.NET offers a lot of functionality, but ADO.NET becomes much more when combined with the data-aware server controls.

The DataGrid Control

The workhorse of these controls is the DataGrid. As we've seen in previous examples, this control makes it simple to display data from the database. The simplest way to add a DataGrid is as follows:

<asp:DataGrid id=DataGrid1 runat="server" />

The ID property gives us something we can write code against. By saying runat=server, we can handle server-side events, and change the properties of this control with code.

DataGrid Appearance

Right out of the box, the DataGrid gives you a lot of control over how it looks (see Listing 4.17).

Listing 4.17. Controlling the appearance of ...

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