Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSSClass not working

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
US
I have a DataGrid that I am trying to run with a CssClass but the class does not get applied. I want the Alternating rows to be "teal" and I want to use a class, but it doesn't seem to work.

Code:
<asp:dataGrid id="DataGrid1" 
	runat="server" 
	footerstyle-horizontalalign="center" 
	AutoGenerateColumns="false"
	CellPadding="0"
	CellSpacing="0"

        ShowFooter="true"
	BorderColor="Gray"
	style="margin-left:3px"  HeaderStyle-Font-Bold="true" HeaderStyle-VerticalAlign="Bottom"
	border="1">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"  CssClass="teal" />

The .css file has only the teal entry in it:

.teal {
color:#4AAABD
}

This does not get applied.

But if I change the CssClass to Backcolor it does get applied.

<AlternatingItemStyle BorderWidth="0px" BorderStyle="None" BackColor="teal" />

Why is that?

Thanks,

Tom
 
What apparently is happening is that if you use a Class in the AlternatingRowStyle, you MUST use a class in the RowStyle tag.

Below, the class will not be applied in the AlternatingRowStyle because the RowStyle is using attributes to apply styles and not a class so it overwrites the class in the AlternatingRowStyle

Code:
<asp:GridView id="GridView1" 
		runat="server" 
		footerstyle-horizontalalign="center" 
		AutoGenerateColumns="false"
		CellPadding="0"
		CellSpacing="0"

            ShowFooter="true"
		BorderColor="Gray"
		style="margin-left:3px"  HeaderStyle-Font-Bold="true" HeaderStyle-VerticalAlign="Bottom"
		border="1">
<AlternatingRowStyle BorderWidth="0px" BorderStyle="None" CssClass="teal" />
<RowStyle  BackColor="#E9E9E9" ForeColor="#0000FF"/>            
<headerstyle CssClass="gridheader"/>            
<pagerstyle BackColor="Red" />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top