R
Ram
Is it possible to control the appearence of data grid control using external
style sheets ?
If so, what should be the syntax ?
Thanks,
Ram
style sheets ?
If so, what should be the syntax ?
Thanks,
Ram
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
done any styling of the control) and achieve the same results using CSS tags vs. styling it
yourself.
programming (especially if you'veScott said:You can't really change the display of the DataGrid without some
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
Kevin Spencer said:programming (especially if you'veYou can't really change the display of the DataGrid without somedone any styling of the control) and achieve the same results using CSS tags vs. styling it
yourself.
I'm afraid I have to take issue with this statement. It is certainly
possible to assign a single CSS Class to a Data Grid, and define completely
the styles that each HTML element in the DataGrid should have.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
programming (especially if you'veScott said:You can't really change the display of the DataGrid without somedone 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
Scott said:Then how do you style normal items vs. alternating items? If you don't provide styles on the
control for normal vs. alternating items they both come out as normal
true of the selected items in the DataGrid. You can do a lot with a single CSS but if you want the
kind of styling that the control has built-in you have to "classify" the tags of the underling
table.
Though, if you have some way to do this in a single CSS class, I love to see it.
Scott
programming (especially if you'veYou can't really change the display of the DataGrid without someCSSdone any styling of the control) and achieve the same results using
tags vs. styling ityourself.
I'm afraid I have to take issue with this statement. It is certainly
possible to assign a single CSS Class to a Data Grid, and define completely
the styles that each HTML element in the DataGrid should have.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
programming (especially if you'veScott said:You can't really change the display of the DataGrid without someCSSdone any styling of the control) and achieve the same results using
tags vs. styling itoverrideyourself.
What we do is to create our own derived class from DataGrid and
the the OnItemCreatedyoumethod to attach a css classes to the various bits of the DataGrid (if
really want to do atostrict 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
the DataGrid using theCssClass 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
Kevin Spencer said:See http://www.csszengarden.com
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
Scott said:Then how do you style normal items vs. alternating items? If you don't provide styles on the
control for normal vs. alternating items they both come out as normaltrue of the selected items in the DataGrid. You can do a lot with a single CSS but if you want the
kind of styling that the control has built-in you have to "classify" the tags of the underling
table.
Though, if you have some way to do this in a single CSS class, I love to see it.
Scott
You can't really change the display of the DataGrid without some
programming (especially if you've
done any styling of the control) and achieve the same results using CSS
tags vs. styling it
yourself.
I'm afraid I have to take issue with this statement. It is certainly
possible to assign a single CSS Class to a Data Grid, and define completely
the styles that each HTML element in the DataGrid should have.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
You can't really change the display of the DataGrid without some
programming (especially if you've
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
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.