protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
// e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
// e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}
解决方案 »
- asp.net session过期后 不能回退重新登录
- 关于DIV布局的问题
- 为什么html里明明有这个控件,在.cs文件里也可通过代码提示写出这个控件名,可是运行却提示不存在此控件的错误?
- gridview 行的选定
- 请教如何在提交时的检测函数中使用session中的变量
- 我都问一千次了,ASP.NET2.0中把GridView中的数据导入到excel中时总是要出错,有没有正确的源码啊?谢谢啦!
- 请问测试代码如何编写●●●●●●
- asp.net mvc3 下开发,下面是我的前台代码,想请教大神,怎么做这个页面的后台,因为下列代码是copy别人php开发的,所以不清楚怎么弄,谢谢
- 使用了未赋值的局部变量,大家看看是怎么回事啊
- 如何动态调用WebUserControl
- 求助 编译器错误消息: CS1061
- 使用母版页时内容页如何使用javascript?
http://dotnet.aspx.cc/file/Change-Gridview-Row-Background-When-mouseover.aspx你的代码应该可以你设置样式代码怎么写的?
class="table" runat="server" AutoGenerateColumns="False"
DataKeyNames="KaiHaoID"
onrowcommand="gvKaiHao_RowCommand"
width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"
onrowdatabound="gvKaiHao_RowDataBound">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f3f3" ItemStyle-BackColor="#ffffff" ItemStyle-Height="30" HeaderStyle-Height="30">
<HeaderTemplate>
手机号码
</HeaderTemplate>
<ItemTemplate>
<%# Eval("Phone") %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="RName" HeaderText="R类型" ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f3f3" ItemStyle-BackColor="#ffffff" ItemStyle-Height="30" HeaderStyle-Height="30" ItemStyle-ForeColor="Red"/>
<asp:BoundField DataField="DepartmentName" HeaderText="部门" ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f3f3" ItemStyle-BackColor="#ffffff" ItemStyle-Height="30" HeaderStyle-Height="30"/>
</Columns>
</asp:GridView>
就类似这样的
{
//鼠标移动颜色
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=style.backgroundColor;style.backgroundColor='#add8e6'");
e.Row.Attributes.Add("onmouseout", "style.backgroundColor=c");
//设置悬浮鼠标指针形状为"小手"
e.Row.Attributes["style"] = "Cursor:hand"; }
}