Make links different color in the datagrid

M

Mike Chamberlain

Hi.

I'm using the standard datagrid control in my ASP.NET page. I have the
latest version and all service packs of the framework installed. I am
using the property builder to create my grid. My question is simple:
How do I make the links in different cells adopt a specific CSS class?

For instance, my header row in set to maroon and my links set to white.
This makes the sortable columns headings display nicely (white on
maroon background). But if I try to use a link somewhere else in my
grid (ie. a Hyperlink column) then it also appears as white on a WHITE
background.

How do I make the links in the header row use CSS class .linkHeader, but
make the links in the hyperlink column use .linkStandard? I tried the
following but obviously it doesn't work:

<asp:HyperLinkColumn Text="..." DataNavigateUrlField="master_id_account"
DataNavigateUrlFormatString="Edit.aspx?masterIdAccount={0}"
CssClass="linkStandard"></asp:HyperLinkColumn>

['System.Web.UI.WebControls.HyperLinkColumn' does not have a property
named 'CssClass'.]

Mike
 
M

Mike Chamberlain

Mike said:
Hi.

I'm using the standard datagrid control in my ASP.NET page. I have the
latest version and all service packs of the framework installed. I am
using the property builder to create my grid. My question is simple:
How do I make the links in different cells adopt a specific CSS class?

For instance, my header row in set to maroon and my links set to white.
This makes the sortable columns headings display nicely (white on
maroon background). But if I try to use a link somewhere else in my
grid (ie. a Hyperlink column) then it also appears as white on a WHITE
background.

How do I make the links in the header row use CSS class .linkHeader, but
make the links in the hyperlink column use .linkStandard? I tried the
following but obviously it doesn't work:

<asp:HyperLinkColumn Text="..." DataNavigateUrlField="master_id_account"
DataNavigateUrlFormatString="Edit.aspx?masterIdAccount={0}"
CssClass="linkStandard"></asp:HyperLinkColumn>

['System.Web.UI.WebControls.HyperLinkColumn' does not have a property
named 'CssClass'.]

Mike

I found a partial workaround myself. First set the UseAccessibleHeader
property of the grid to True, which tells it to render the table
properly (using <TH> tags for the header cells rather than <TD> - why
this isn't the default is beyond me). Then, two styles can be defined

TH A { color:white; }
TD A { color:maroon; }

which works fine for now. But what happens if I want to have a link of
one color in one Hyperlink column, and one of a different color in another?

Any suggestions appreciated.

Mike
 
R

Riki

Mike said:
Hi.

I'm using the standard datagrid control in my ASP.NET page. I have
the latest version and all service packs of the framework installed. I am
using the property builder to create my grid. My question is
simple: How do I make the links in different cells adopt a specific
CSS class?
For instance, my header row in set to maroon and my links set to
white. This makes the sortable columns headings display nicely
(white on maroon background). But if I try to use a link somewhere
else in my grid (ie. a Hyperlink column) then it also appears as
white on a WHITE background.

How do I make the links in the header row use CSS class .linkHeader,
but make the links in the hyperlink column use .linkStandard? I
tried the following but obviously it doesn't work:

<asp:HyperLinkColumn Text="..."
DataNavigateUrlField="master_id_account"
DataNavigateUrlFormatString="Edit.aspx?masterIdAccount={0}"
CssClass="linkStandard"></asp:HyperLinkColumn>
['System.Web.UI.WebControls.HyperLinkColumn' does not have a property
named 'CssClass'.]

Mike

If the other columns don't contain links, you can set the CssClass property
of the ItemStyle and AlternatingItemStyle.
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top