change gridview color on mouse out

F

fredd00

how can i change the back color on mouse out to the color specified in
the grid view declaration

in the gridview declaration

<AlternatingRowStyle BackColor="#CECECE" />
<RowStyle BackColor="#DEDEDE" />

the RowDataBound (i don't want to have to specify the color code, i
might want to use themes in the future)

protected virtual void RowDataBound(object sender,
GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Alternate)
{
e.Row.Attributes.Add("onmouseout",
string.Format("this.style.backgroundColor='{0}'", "#CECECE"));
}
else
{
e.Row.Attributes.Add("onmouseout",
string.Format("this.style.backgroundColor='{0}'", "#DEDEDE"));
}
e.Row.Attributes.Add("onmouseover",
"this.style.backgroundColor='orange'; this.style.cursor='pointer';");

}
}
 
G

Guest

how can i change the back color on mouse out to the color specified in
the grid view declaration

you can do it using css

..row1
{
background: #CECECE;
}
..row2
{
background: #DEDEDE;
}
..row1:hover, .row2:hover
{
cursor: pointer;
background-color: orange;
}


so, in this case your grid coding should be

<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
 

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,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top