CSS styles and item colours

P

Paul Cheetham

Hi,

I have a datagrid, where I have used CSS classes for the item style and
alternating item style.
The grid draws great when I load the page, but I have problems when I
want to select a line by clicking on it.

When a row is clicked on, I set the backcolor of that row in order to
show it highlighted.
BEfore I do this I read the current value of Backcolor for that row, so
that I can set it back to the same colour when it is not selected.

The problem is that because the colours of the rows are set in a CSS
style, the CSS values are not reflected in the BackColor property of the
datagrid rows.
If I explicitly set the row colours in the databound event, then
everything works fine.

How can I either:
- Read the required colour from the CSS in the databound event and
explicitly set the colour at that point.
OR
- Read the colour actaully used to draw the row when I click on it



I am using .Net 1.1 and VS 2003


Thankyou.

Paul Cheetham
 
E

Elton Wang

Hi Paul,

I think that even if you use CSS for datagrid items, you can still read
backcolor value of item for late set it back.

IF it really doesn't work, you can set color back by
selectedItem.BackColor = datagrid.Items[selectedIndex + 2].BackColor //(or
selectedIndex - 2)

HTH
 
P

Paul Cheetham

Elton,

The items do not have a value in Backcolor.
It does not matter whether I read the currently selected item, or
another one in the grid, it always returns 0, because a colour has never
been set.

I really need to be able to access the CSS class that it is using.


Thanks.

Paul


Elton said:
Hi Paul,

I think that even if you use CSS for datagrid items, you can still read
backcolor value of item for late set it back.

IF it really doesn't work, you can set color back by
selectedItem.BackColor = datagrid.Items[selectedIndex + 2].BackColor //(or
selectedIndex - 2)

HTH


Paul Cheetham said:
Hi,

I have a datagrid, where I have used CSS classes for the item style and
alternating item style.
The grid draws great when I load the page, but I have problems when I want
to select a line by clicking on it.

When a row is clicked on, I set the backcolor of that row in order to show
it highlighted.
BEfore I do this I read the current value of Backcolor for that row, so
that I can set it back to the same colour when it is not selected.

The problem is that because the colours of the rows are set in a CSS
style, the CSS values are not reflected in the BackColor property of the
datagrid rows.
If I explicitly set the row colours in the databound event, then
everything works fine.

How can I either:
- Read the required colour from the CSS in the databound event and
explicitly set the colour at that point.
OR
- Read the colour actaully used to draw the row when I click on it



I am using .Net 1.1 and VS 2003


Thankyou.

Paul Cheetham
 
E

Elton Wang

'items' means whole 'rows' of datagrid. If you want to set any row, it's
datagrid.Items[row_index]. I mean

datagrid.Items[row_index].BackColor

or in any datagrid event

e.Item.BackColor

HTH


Paul Cheetham said:
Elton,

The items do not have a value in Backcolor.
It does not matter whether I read the currently selected item, or another
one in the grid, it always returns 0, because a colour has never been set.

I really need to be able to access the CSS class that it is using.


Thanks.

Paul


Elton said:
Hi Paul,

I think that even if you use CSS for datagrid items, you can still read
backcolor value of item for late set it back.

IF it really doesn't work, you can set color back by
selectedItem.BackColor = datagrid.Items[selectedIndex + 2].BackColor
//(or selectedIndex - 2)

HTH


Paul Cheetham said:
Hi,

I have a datagrid, where I have used CSS classes for the item style and
alternating item style.
The grid draws great when I load the page, but I have problems when I
want to select a line by clicking on it.

When a row is clicked on, I set the backcolor of that row in order to
show it highlighted.
BEfore I do this I read the current value of Backcolor for that row, so
that I can set it back to the same colour when it is not selected.

The problem is that because the colours of the rows are set in a CSS
style, the CSS values are not reflected in the BackColor property of the
datagrid rows.
If I explicitly set the row colours in the databound event, then
everything works fine.

How can I either:
- Read the required colour from the CSS in the databound event and
explicitly set the colour at that point.
OR
- Read the colour actaully used to draw the row when I click on it



I am using .Net 1.1 and VS 2003


Thankyou.

Paul Cheetham
 

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

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top