472,096 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

Alternating Row style in DataGridView

how can I change the font color for an alternating row where the
column data is formatted as a link?

setting a style in the stylesheet for

a {

color:white;
}

makes all links white (as expected)

and changing the ForeColor property in the AlternatingRowStyle options
does not effect the <atag in the data column - it still shows up
blue. Placing additional formatting for the column will not help since
it will apply to all data in the column and not just the alternating
rows.
Mike

Jan 25 '07 #1
4 5578
Did you try AlternatingRowStyle.CssClass?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<mi**@5starserv.comwrote in message
news:11*********************@l53g2000cwa.googlegro ups.com...
how can I change the font color for an alternating row where the
column data is formatted as a link?

setting a style in the stylesheet for

a {

color:white;
}

makes all links white (as expected)

and changing the ForeColor property in the AlternatingRowStyle options
does not effect the <atag in the data column - it still shows up
blue. Placing additional formatting for the column will not help since
it will apply to all data in the column and not just the alternating
rows.
Mike

Jan 25 '07 #2

Hi,
Try add a css for the alternate row style....
In proproperty grid of the grid view you have alternaterowstyle...
in the cssclass field put your custom css....
and then in stylesheet file add the styles....

..alternaterow
{
background-color:Teal;
}
..alternaterow a
{
color:Yellow;
}
..alternaterow a:hover
{
color:red;
}

Thanks

Masudur
http://www.kaz.com.bd
http://munnacs.blogspot.com

On Jan 25, 8:24 pm, m...@5starserv.com wrote:
how can I change the font color for an alternating row where the
column data is formatted as a link?

setting a style in the stylesheet for

a {

color:white;

}makes all links white (as expected)

and changing the ForeColor property in the AlternatingRowStyle options
does not effect the <atag in the data column - it still shows up
blue. Placing additional formatting for the column will not help since
it will apply to all data in the column and not just the alternating
rows.

Mike
Jan 25 '07 #3
I added the following to my stylesheet

..altgridrow {

color: white;

}

and then referenced it in properties for
AlternateRowStyle.CssClass=altgridrow

apparently, since the column data contains a link it regards the
content as <atag and does not use the row style settings.

it might require iterating over the rows and setting the alternating
ones when the page loads or something like that.

I'd love to hear a easier method though :)


On Jan 25, 9:39 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
Did you try AlternatingRowStyle.CssClass?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

<m...@5starserv.comwrote in messagenews:11*********************@l53g2000cwa.go oglegroups.com...
how can I change the font color for an alternating row where the
column data is formatted as a link?
setting a style in the stylesheet for
a {
color:white;
}
makes all links white (as expected)
and changing the ForeColor property in the AlternatingRowStyle options
does not effect the <atag in the data column - it still shows up
blue. Placing additional formatting for the column will not help since
it will apply to all data in the column and not just the alternating
rows.
Mike- Hide quoted text -- Show quoted text -
Jan 25 '07 #4
Works like a charm! Thanks!

On Jan 25, 9:51 am, "Masudur" <munn...@gmail.comwrote:
Hi,
Try add a css for the alternate row style....
In proproperty grid of the grid view you have alternaterowstyle...
in the cssclass field put your custom css....
and then in stylesheet file add the styles....

.alternaterow
{
background-color:Teal;}.alternaterow a
{
color:Yellow;}.alternaterow a:hover
{
color:red;

}Thanks

Masudurhttp://www.kaz.com.bdhttp://munnacs.blogspot.com

On Jan 25, 8:24 pm, m...@5starserv.com wrote:
how can I change the font color for an alternating row where the
column data is formatted as a link?
setting a style in the stylesheet for
a {
color:white;
}makes all links white (as expected)
and changing the ForeColor property in the AlternatingRowStyle options
does not effect the <atag in the data column - it still shows up
blue. Placing additional formatting for the column will not help since
it will apply to all data in the column and not just the alternating
rows.
Mike- Hide quoted text -- Show quoted text -
Jan 25 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Alistair Birch | last post: by
1 post views Thread by Eirik Eldorsen | last post: by
4 posts views Thread by Rob | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.