GridView显示数据特效——鼠标经过行背景高亮并呈手型
2015-11-06 14:39
387 查看
在用GridView控件显示数据时,它的默认的样式很丑,也没有鼠标经过行背景高亮和鼠标呈现手型的特效,今天实现了这个特效。
代码如下。
//鼠标经过行背景高亮并变手型
protected void ClassGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i;
//执行循环,保证每条数据都可以更新
for (i = 0; i <= ClassGridView.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='AliceBlue';this.style.cursor='pointer'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
}
如果只是想要行背景高亮或者添加其他特效只需要修改 e.Row.Attributes.Add中的内容即可。
代码如下。
//鼠标经过行背景高亮并变手型
protected void ClassGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i;
//执行循环,保证每条数据都可以更新
for (i = 0; i <= ClassGridView.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='AliceBlue';this.style.cursor='pointer'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
}
如果只是想要行背景高亮或者添加其他特效只需要修改 e.Row.Attributes.Add中的内容即可。
相关文章推荐
- 分享微信开发Html5轻游戏中的几个坑
- 微软无线镭射简报鲨8000激光笔记本鼠标 - (2)
- 星外ASP.Net的安全设置相关说明
- flex 控件的重要属性
- 鼠标与“助手”的不解之缘
- C#、ASP.NET通用扩展工具类之TypeParse
- Delphi控件ListView的属性及使用方法详解
- Delphi实现窗体感知鼠标滑过并自动隐藏与显示窗口的方法
- web下载的ActiveX控件自动更新
- 实现ASP.NET无刷新下载并提示下载完成的开发思路
- C#、ASP.NET通用扩展工具类之LogicSugar
- WinForm实现按名称递归查找控件的方法
- C#中父窗口和子窗口之间控件互操作实例
- C#、ASP.NET通用工具类IsWhat?(可以判断数字、身份证、数据类型等等)
- C#模拟window操作鼠标的方法
- 程序中常用的种代码
- Android编程之Button控件用法实例分析
- Android控件之CheckBox、RadioButton用法实例分析
- ASP.NET、ASP、PHP、JSP之间有什么区别?
- ASP.NET页面间的传值的几种方法