繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Asp.Net开发 >> Coping with a New Beta - Data Server Control Templates and Editing

Coping with a New Beta - Data Server Control Templates and Editing

2007-07-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:The .NET Framework Beta 2 has many changes that will break applications written in Beta 1. Among these changes is the templates used in Data Server Controls, such as the DataGrid and DataList. The...

The .NET Framework Beta 2 has many changes that will break applications written in Beta 1. Among these changes is the templates used in Data Server Controls, such as the DataGrid and DataList. These are simply syntax changes in how templates are used, not programmatic breaks. In this tutorial you will learn how to use Data Server Control templates. Heck, since its a Friday I'll also show you how to do DataGrid editing at the same time. The downloadable sample code for this article contains files in both Visual Basic.NET and C#.

What Good is a Template?

Templates can be used with the Data Server Controls to provide a custom layout of the data bound to the control. The DataGrid provides a basic grid, with one row for each record, and one table column for each field in the row. Templates can be used with a TemplateColumn to custom format the layout of the column. The DataList provides one row for each record in the data source, and templates are used to format the layout of each row. The Repeater control is entirely custom. Templates are used to provide the layout for the entire Repeater control.

Changing a Name is a Big Deal

In Beta 1 you would use a DataGrid, and set up templates using a TemplateColumn. This is the same in Beta 2, however there are some slight changes to the syntax. In Beta 1 a DataGrid using a TemplateColumn would look like the code in Listing 1.

Listing 1

AutoGenerateColumns="False" >

The majority of the syntax in Listing 1 remains the same. The changes are as follows:

The element changes to

The