System.Web.UI.WebControls Namespace DataGrid Class
Sets the style properties for the individual items in a DataGrid.
<asp:datagrid ...
itemstyle-styleproperty=value
... >
</asp:datagrid>
or
<asp:datagrid ... >
<itemstyle
... template style definition here
</itemstyle>
</asp:datagrid>
A TableItemStyle object that defines the style properties for the individual items in a DataGrid.
Use this property to provide a custom style for the data items in the DataGrid control. Common style attributes that can be set include forecolor, backcolor, font, and content alignment within the cell. Providing different item styles enhances the appearance of the DataGrid control.
To specify a custom style for the items of the DataGrid, declare an <ItemStyle> element between the opening and closing tags of the control. You can then list the style attributes within the opening <ItemStyle> tag.
The below snippet shows setting the ItemStyle property of a DataGrid control at design time.
<asp:datagrid id = "myGrid" runat = "server" cellpadding=5>
<headerstyle backcolor = "navy"
forecolor = "lime"
font-bold />
<itemstyle backcolor = "beige"
font-name = "Bookman Old Style"
font-size = "11pt" font-bold font-italic />
</asp:datagrid>
Show me
DataGrid Members AlternatingItemStyle EditItemStyle SelectedItemStyle HeaderStyle FooterStyle