In the above example it is seen that when an item is not selected for editing, the EditCommandColumn displays an Edit command and on the selection of an item for editing, the EditCommandColumn displays Update and cancel commands.
An item can be selected for editing by clicking the Edit command displayed by an EditCommandColumn. When the Edit command link, is clicked the dgrdEmployeesEditCommand executes and assigns the index number of the selected item to the EdititemIndex property. This results in the item being selected for editing.
Using Styles with a DataGrid
The DataGrid control supports style objects that can be used to customize its appearance. Each style object is an instance of the TableItemStyle class, which has the following properties:
The style used for borders around
The background color displayed for an item
The width of the border
The border color displayed for an item
The Cascading Style Sheet class associated with the item
An instance of the FontInfo class, which indicates how the font should be formatted
The foreground color used for text
The height of the item
The horizontal alignment of the item (possible values are Center, Justify, Left, NotSet, and Right)
The vertical alignment of the item (possible values are Bottom, Middle, NotSet, and Top)
The width of the item
If True, the contents of an item are word-wrapped (the default value is True)
Any of these style properties can be used with the AlternatingItemStyle, EditItemStyle, FooterStyle, HeaderStyle, ItemStyle, and SelectedItemStyle styles of the DataGrid control. When a style property is set while declaring a control, a hyphen (-) can be used instead of the normal period (.) to indicate a property of an object.
The following example, displays the header with a bold, Arial font and a yellow background. Every item is displayed with a 9-point Arial font. Alternate items are displayed with an Alice Blue background