Alternating Row style in DataGridView

M

mike

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 <a> tag 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
 
M

Masudur

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
 
M

mike

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 <a> tag 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 :)




Did you try AlternatingRowStyle.CssClass?

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



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 {

makes all links white (as expected)
and changing the ForeColor property in the AlternatingRowStyle options
does not effect the <a> tag 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 -
 
M

mike

Works like a charm! Thanks!

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
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top