In DataGrid OnClick Event i want to show Some color

K

karunakar

Hi All

In datagrid OnMouseOver iam showing some color
Onmouseout also working fine .
Here my problem is when ever click the pariculat row in DataGrid iam showing
red color that time i am not getting any problem .
when ever mouse was changed paricular row that time color is lossed
"When ever click the particular Row That time i want to show that color &
that time dont loss that color( when ever onMouseover changed)"
Here it's not happening
Here i am using this code "Onclick event " it is showing that color but it
is not stable that color :
e.Item.Attributes.Add("onclick","this.style.backgroundColor='Red';
this.style.cursor='hand';");

e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver';
this.style.cursor='hand';");

e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='yellow';
this.style.cursor='hand';");


Regards,
Karunakara Rao.
 
D

David Jessee

instead of setting the background color, use style defined in your style
sheet. This makes it so you can change the formatting without recompiling.
Also, this means you can...

<style>
..hoverStyle {background-color: silver; cursor:hand}
..regularStyle {background-color: yellow; cursor:hand}
..clickedStyle (background-color: red; cursor:hand}
</style>
....and in your code...

e.Item.Attributes.Add("onclick","this.className='clickedStyle';");

e.Item.Attributes.Add("onmouseover",
"if(this.className!='clickedStyle')this.className='hoverStyle';");


e.Item.Attributes.Add("onmouseout","if(this.className!='clickedStyle')this.c
lassName='regularStyle';")

.....and be sure to add, for default state...
e.Item.Attributes.Add("class","regularStyle")
 
K

karunakar

Thank u it's working fine

Here what ever select in datagrid row that can be deselect the row (when
ever click another row that is not happend in my DataGrid.)
I want deselect the partcular row

Regards
Karunakara Rao
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top