IN THIS CHAPTER
As we've seen in numerous examples throughout this book, when using the DataGrid Web control, you can explicitly specify the columns that should appear in the DataGrid by using the Columns tag. There are a number of column types, such as the BoundColumn, which is useful for displaying data from a DataSource field, and the ButtonColumn, which creates a command button for each row. There might be times when you want to display data from a column in a certain way. You might want to display a particular column with a format not supported by the DataFormatString property of the BoundColumn, such as formatting a string as a telephone number. For example, imagine that you have a DataGrid that displays the contents of an online guestbook, as we saw in Chapter 8. One advanced formatting feature you might like to add to the column that displays the message a user adds to the guestbook is the censoring of profanity. That is, you'd like all swear words to be replaced by asterisks, such as replacing "hell" with "****". Fortunately, you can create your own DataGrid column controls, and use them in your DataGrid, just like you use the built-in DataGrid column controls. In this chapter, we will examine how to create and use custom DataGrid column controls, and discuss the advantages of using them. |