If you have the color preference of each user saved on a field in your
datatable that you bound to the datagrid then you can handle the
ItemDataBound event to change the color or each row like this:
protected void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Style.Add("background-color",((DataRowView)e.Item.DataItem)["UserPreferredColor"]);
}
}
--
HTH,
Phillip Williams
http://www.societopia.net http://www.webswapp.com
"Sonny Sablan" wrote:
I would like to dynamically change the row color in a datagrid...
I have a list (from a db) where users can mark certain records. When they
are marked I want to display the row in the specified color of the user. i.e
Joe = BLUE, Ed = YELLOW, etc. All other rows can be set to NO COLOR.
I cannot seem to find a way to do this with the web control. Can you help?
Sonny