Reputation: 27996
I am working on asp.net 3.5 application. I have a datagrid. I want to change the row color based on the dataitem to which the row is bound. I know this can be easy done in gridview using rowdatabound event but this event it not available in Datagrid control. Please suggest me how to use it?
Regards, Asif Hameed
Upvotes: 1
Views: 2934
Reputation: 21365
Have you tried:
protected void grdSomething_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
e.Item.BackColor = Color.AliceBlue;
}
The tag
<asp:DataGrid runat="server" ID="grdSomething" AutoGenerateColumns="False"
onitemdatabound="grdSomething_ItemDataBound">
The output:
Upvotes: 1