onmouse over in datagrid


J

Jairo Nieto

Hi i am currently developing a Datagrid that changes background color when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender, DataGridItemEventArgs e)

{ if(e.Item.Cells[2].Text != null && e.Item.Cells[2].Text != " ")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell color to a css
class. i have tried assigning the class directly, changing style for class,
but nothing seems to work. How can i do it?

Thx :)
 
Ad

Advertisements

J

Jairo Nieto

Nope, i havent been able to solve it :(

Alvin Bruney said:
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
Hi i am currently developing a Datagrid that changes background color when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender, DataGridItemEventArgs e)

{ if(e.Item.Cells[2].Text != null && e.Item.Cells[2].Text != " ")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell color to a css
class. i have tried assigning the class directly, changing style for class,
but nothing seems to work. How can i do it?

Thx :)
 
A

Alvin Bruney [MVP]

why do you need to assing to a css class? what are you trying to achieve?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
Nope, i havent been able to solve it :(

Alvin Bruney said:
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
Hi i am currently developing a Datagrid that changes background color when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender, DataGridItemEventArgs e)

{ if(e.Item.Cells[2].Text != null && e.Item.Cells[2].Text != " ")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell color to a css
class. i have tried assigning the class directly, changing style for class,
but nothing seems to work. How can i do it?

Thx :)
 
A

Alvin Bruney [MVP]

sorry
i meant to say why do you need to assign to a css class

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Alvin Bruney said:
why do you need to assing to a css class? what are you trying to achieve?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
Nope, i havent been able to solve it :(

Alvin Bruney said:
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Hi i am currently developing a Datagrid that changes background
color
when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender, DataGridItemEventArgs e)

{ if(e.Item.Cells[2].Text != null && e.Item.Cells[2].Text != " ")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell color to
a
css
class. i have tried assigning the class directly, changing style for
class,
but nothing seems to work. How can i do it?

Thx :)
 
J

Jairo Nieto

I need a css class because the datagrid is part of a user control, that will
be used over and over again in different proyects, that use different
styles, and hence different colours, so i need the datagrid to be able to
asume a css class on a mouse over, mouse out event (specially on the mouse
out event so that it will assume the color it had before, given by the css
class). So far, all the examples i have found assign static colors to the
datagrid on mouseover/mouseout, but i need to be able to assign them
dinamically.

Thanks :)

Alvin Bruney said:
sorry
i meant to say why do you need to assign to a css class

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Alvin Bruney said:
why do you need to assing to a css class? what are you trying to achieve?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
Nope, i havent been able to solve it :(

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Hi i am currently developing a Datagrid that changes background color
when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender, DataGridItemEventArgs e)

{ if(e.Item.Cells[2].Text != null && e.Item.Cells[2].Text !=
"&nbsp;")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell color
to
 
Ad

Advertisements

A

Alvin Bruney [MVP]

The datagrid exposes a CssClass read/write attribute. You can hook into this
property like so
DataGrid1.CssClass = "fillClass"

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
I need a css class because the datagrid is part of a user control, that will
be used over and over again in different proyects, that use different
styles, and hence different colours, so i need the datagrid to be able to
asume a css class on a mouse over, mouse out event (specially on the mouse
out event so that it will assume the color it had before, given by the css
class). So far, all the examples i have found assign static colors to the
datagrid on mouseover/mouseout, but i need to be able to assign them
dinamically.

Thanks :)

Alvin Bruney said:
sorry
i meant to say why do you need to assign to a css class

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Alvin Bruney said:
why do you need to assing to a css class? what are you trying to achieve?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Nope, i havent been able to solve it :(

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Hi i am currently developing a Datagrid that changes background color
when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender, DataGridItemEventArgs e)

{ if(e.Item.Cells[2].Text != null && e.Item.Cells[2].Text !=
"&nbsp;")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell
color
 
J

Jairo Nieto

So the answer is to define the style for the whole datagrid and not just the
row? then on the mouseover//mouseout i would change the whole datagrid
class, with only the row color being different?

Alvin Bruney said:
The datagrid exposes a CssClass read/write attribute. You can hook into this
property like so
DataGrid1.CssClass = "fillClass"

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
I need a css class because the datagrid is part of a user control, that will
be used over and over again in different proyects, that use different
styles, and hence different colours, so i need the datagrid to be able to
asume a css class on a mouse over, mouse out event (specially on the mouse
out event so that it will assume the color it had before, given by the css
class). So far, all the examples i have found assign static colors to the
datagrid on mouseover/mouseout, but i need to be able to assign them
dinamically.

Thanks :)

Alvin Bruney said:
sorry
i meant to say why do you need to assign to a css class

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
why do you need to assing to a css class? what are you trying to achieve?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Nope, i havent been able to solve it :(

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Hi i am currently developing a Datagrid that changes background
color
when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender,
DataGridItemEventArgs
e)
{ if(e.Item.Cells[2].Text != null && e.Item.Cells[2].Text !=
"&nbsp;")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell
color
to
a
css
class. i have tried assigning the class directly, changing
style
for
class,
but nothing seems to work. How can i do it?

Thx :)
 
Ad

Advertisements

A

Alvin Bruney [MVP]

no you can apply the css to lower levels such as to a particular cell.
Consider this juicy snippet of code in the itemdatabound event handler

e.Item.Cells[0].CssClass = "cssclass";

The individual cells are as granular as you can get. Everything inbetween is
fair game

htt


--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
So the answer is to define the style for the whole datagrid and not just the
row? then on the mouseover//mouseout i would change the whole datagrid
class, with only the row color being different?

Alvin Bruney said:
The datagrid exposes a CssClass read/write attribute. You can hook into this
property like so
DataGrid1.CssClass = "fillClass"

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Jairo Nieto said:
I need a css class because the datagrid is part of a user control,
that
will
be used over and over again in different proyects, that use different
styles, and hence different colours, so i need the datagrid to be able to
asume a css class on a mouse over, mouse out event (specially on the mouse
out event so that it will assume the color it had before, given by the css
class). So far, all the examples i have found assign static colors to the
datagrid on mouseover/mouseout, but i need to be able to assign them
dinamically.

Thanks :)

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
sorry
i meant to say why do you need to assign to a css class

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
why do you need to assing to a css class? what are you trying to
achieve?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Nope, i havent been able to solve it :(

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Hi i am currently developing a Datagrid that changes background
color
when
the user rolls over his mouse on a row.

Here's how I handle it:
void dg_menu_ItemDataBound(object sender,
DataGridItemEventArgs
e)

{ if(e.Item.Cells[2].Text != null &&
e.Item.Cells[2].Text
!=
"&nbsp;")

{ e.Item.Cells[3].Attributes.Add("onmouseover",
"this.style.backgroundColor='white'");

e.Item.Cells[3].Attributes.Add("onmouseout",
"this.style.backgroundColor='blue'");

}

}

So far so good. My problem is that i need to asign the cell color
to
a
css
class. i have tried assigning the class directly, changing style
for
class,
but nothing seems to work. How can i do it?

Thx :)
 

Top