In DataGrid OnClick Event i want to show Some color

  • Thread starter Thread starter karunakar
  • Start date Start date
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.
 
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")
 
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
 
Back
Top