Formatting the DataGrid's Data

In the previous example a selected customer's information is displayed. Looking back at Figure 16.4, you can see the customer's information displayed in the DataGrid. Notice that the DataGrid displays each field in the DataSource as a column in the DataGrid. This is because we have not specified which columns should appear in the DataGrid, so by default all of the DataSource's fields are added as columns. Additionally, note that the format of the DateBecameCustomer column displays both the date and time.

We can customize the output of the ShowSingleCustomer.aspx ASP.NET Web page by specifying which columns should appear in the DataGrid. When doing this, we can also specify a data-formatting style for each column. ...

Get SAMS Teach Yourself ASP.NET in 24 Hours now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.