Summary

In this chapter, we examined how to create our own custom DataGrid column classes. These classes need to be derived, either directly or indirectly, from the DataGridColumn class, and need to override the InitializeCell() method. After these simple criteria have been met, you can add whatever functionality necessary to the class. To use the custom DataGrid column class in an ASP.NET Web application, the class needs to be compiled into an assembly (a DLL file) and then copied to the Web application's /bin directory. Additionally, the @Register directive needs to be included at the top of all ASP.NET Web pages that use the control.

If you want to create a custom DataGrid column that has a lot in common with an existing DataGrid column, such as a BoundColumn or ButtonColumn, you can have the custom column derived directly from the class whose functionality it closely resembles. By deriving from such a class, you get at your disposal all the properties and methods from the DataGrid column class being inherited. As we saw in Listing 12.3, a LimitColumn class can be implemented with a short amount of code by being derived from the BoundColumn class.

Custom DataGrid column classes can also be used to provide functionality that is not otherwise possible in the DataGrid Web control. A classic example is the use of a RowSelectorColumn, which presents a series of radio buttons in each row of a particular column, with the caveat that only one such radio button may be selected. This functionality is, to my knowledge, impossible to provide in a DataGrid without using a custom DataGrid column, such as Andy Smith's RowSelectorColumn.



ASP. NET Data Web Controls Kick Start
ASP.NET Data Web Controls Kick Start
ISBN: 0672325012
EAN: 2147483647
Year: 2002
Pages: 111

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net