asp.netGridView和DataList实现鼠标移到行行变色
ASP 实现 鼠标 变色 netGridview DataList 移到
2023-06-13 09:14:08 时间
在GridView控件的RowDataBound事件里添加以下代码
if(e.Row.RowType==DataControlRowType.DataRow)
{
//当鼠标移到行上时更改背景色
e.Row.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor="#EE82EE"");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout","this.style.backgroundColor=c");
}
在设计页面添加了DataList控件后,我在使用DataList绑定数据时是通过单元格来绑定的,因此鼠标效果就在源代码页面去实现,如下例所示
<asp:DataListID="DataList1"runat="server"BorderWidth="1">
<ItemTemplate>
<tronmouseover="this.style.backgroundColor="#8EC26F""onmouseout="this.style.backgroundColor=""">
<td>
<asp:LabelID="Label1"runat="server"Text="<%#DataBinder.Eval(Container,"DataItem.ID")%>"></asp:Label>
</td>
<td>
<asp:LabelID="Label2"runat="server"Text="<%#DataBinder.Eval(Container,"DataItem.Area")%>"></asp:Label>
</td>
</tr>
</ItemTemplate>
<HeaderTemplate>
Header1</td>
<td>Header2
</HeaderTemplate>
</asp:DataList>
if(e.Row.RowType==DataControlRowType.DataRow)
{
//当鼠标移到行上时更改背景色
e.Row.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor="#EE82EE"");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout","this.style.backgroundColor=c");
}
在设计页面添加了DataList控件后,我在使用DataList绑定数据时是通过单元格来绑定的,因此鼠标效果就在源代码页面去实现,如下例所示
<asp:DataListID="DataList1"runat="server"BorderWidth="1">
<ItemTemplate>
<tronmouseover="this.style.backgroundColor="#8EC26F""onmouseout="this.style.backgroundColor=""">
<td>
<asp:LabelID="Label1"runat="server"Text="<%#DataBinder.Eval(Container,"DataItem.ID")%>"></asp:Label>
</td>
<td>
<asp:LabelID="Label2"runat="server"Text="<%#DataBinder.Eval(Container,"DataItem.Area")%>"></asp:Label>
</td>
</tr>
</ItemTemplate>
<HeaderTemplate>
Header1</td>
<td>Header2
</HeaderTemplate>
</asp:DataList>
相关文章
- ASP结合MySQL:实现快速数据库连接(asp如何连接mysql)
- ASP操作MySQL数据库的实现(asp读取mysql)
- ASP连接MySQL:简单实现数据库交互(asp链接mysql)
- ASP程序如何利用MySQL更好地实现服务(asp需要用到mysql)
- 快速搭建ASP应用MySQL配置指南(asp配置mysql)
- 库ASP实现MySQL数据库的轻松访问(asp读取mysql数据)
- ASP绑定MySQL实现功能强大的数据库访问(asp绑定mysql)
- ASP登录注册实现MySQL用户管理(asp登录注册mysql)
- ASP操作MySQL数据库实现简单便捷功能(asp用mysql数据库)
- ASP程序操作MySQL数据库实现数据库驱动开发(asp用mysql)
- ASP技术与MySQL数据库实现无缝结合(asp可以和mysql)
- 数据库ASP连接Oracle数据库简单实现实时数据访问(asp连续oracle)
- ASP程序开发与Oracle数据库结合实现(asp与oracle)
- ASP实现SQL备份、恢复
- asp下制做行背景颜色交替变换的表格
- asp实现图片右键滑轮控制大小的函数
- asp.net下实现URL重写技术的代码
- ASP利用XMLHTTP实现表单提交以及cookies的发送的代码
- asp.netgridview中用checkbox全选的几种实现的区别
- javascript或asp实现的判断身份证号码是否正确两种验证方法
- ASP与Excel结合生成数据表和Chart图的代码
- CentOS5.1下跑Mono和Asp.net的实现方法分享
- asp.netc#采集需要登录页面的实现原理及代码
- Asp.Net生成静态页面的实现方法