done any styling of the control) and achieve the same results using CSS tags vs. styling it
yourself.
What we do is to create our own derived class from DataGrid and override the the OnItemCreated
method to attach a css classes to the various bits of the DataGrid (if you really want to do a
strict job of this, then you have to "remove" any programmer styling). It's not perfect but it works
most of the time.
In OnItemCreated, assuming that you've already assigned a css class to the DataGrid using the
CssClass property; we do something like the following:
OnItemCreated(object sender, DataGridEventArgs e)
ListItemType t = e.Item.ItemType;
DataGridItem r = e.Item.Controls[0].Parent as DataGridItem;
if (t == ListItem.Item)
r.CssClass = this.CssClass + "Itm";
else if (t == ListItem.AlternatingItm)
r.CssClass = this.CssClass + "AltItm";
// do the same for the rest of the types
In your Css file you could have something like
.DataGrid {
}
.DataGridItm {
}
.DataGridAltItm {
}
Is it possible to control the appearence of data grid control using external
style sheets ?
If so, what should be the syntax ?
Thanks,
Ram