repeater单双行颜色不同,gridview repeater DataList 鼠标经过改变背景颜色
1.gridview
双击GridView的OnRowDataBound事件;
在后台的GridView1_RowDataBound()方法添加代码,最后代码如下所示:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{ //首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{ //当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#C0C0C0'"); //当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
2.repeater,DataList
DataList 和 Repeater 在 HTML界面表格<tr>标记中加入如下代码:
onmouseover="this.style.backgroundColor='FloralWhite'" onmouseout="this.style.backgroundColor='' "
3. 单双行不同的颜色。而且鼠标移动上去可以变换颜色
<script type="text/javascript">
function fOver(obj){
c=obj.style.backgroundColor;
obj.style.backgroundColor="#CAD3E4";
}
function fOut(obj){
obj.style.backgroundColor=c;
}
</script>
<asp:Repeater ID="rptUser" runat="server">
<ItemTemplate>
<tr style='background-color:<%#(Container.ItemIndex%2==0)?"red":"green"%>' onmouseover="fOver(this);" onmouseout="fOut(this);">
<td><%#Eval("UID")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
repeater单双行颜色不同,gridview repeater DataList 鼠标经过改变背景颜色的更多相关文章
- table 控制单双行颜色以及鼠标hover颜色 table光棒
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- html table单双行颜色间隔(转载)
直接上代码: <html> <head> <meta http-equiv="Content-Type" content="text/htm ...
- js改变,设置table单双行颜色,jquery改变,设置table单双行颜色
1.js实现单双行以不同颜色显示 $(document).ready(function () { var color = "#ffeab3"; $("#GvList tr ...
- Js实现table单双行交替色
依稀记得,当初我刚学编程的时候还学过怎么实现表格单双行交替色,现如今早已记不清当时的实现思路,这两天突然想起,没事就自己写了一小段代码,也不知道是否是当年的思路,不过不用纠结这个问题.:) 代码很简单 ...
- OpenGL的glClearColor和glClear改变背景颜色
OpenGL的glClearColor和glClear改变背景颜色 结合以下两个函数void glClearColor(GLclampf red, GLclampf green, GLclamp ...
- [JS9] document's bgColor改变背景颜色
<HTML> <HEAD> <TITLE>设置背景颜色</TITLE> </HEAD> <BODY> <CENTER> ...
- iOS 创建多个button实现点击改变背景颜色
工程中需要实现与UISegmentedControl效果相似的一排一共十个button,如下图.但是SegmentedControl修改不太方便,就用button替代, 循环创建十个button,点击 ...
- 奇偶选择器:使用odd和even属性实现表格单双行颜色相间和不同
一.奇偶选择器 表格在呈现数据的时候我们为了方便观看,而隔行显示不同的颜色,虽然可以用用类选择器 class实现这种效果,但是未免太过麻烦,为了更加简便地表现这种特殊的效果我们需要用到一种特殊的选择器 ...
- css单双行样式
#random_box li:nth-child(odd) {//双行 background: #fff5c4; } #random_box li:nth-child(even) {//单行 back ...
随机推荐
- Android集成支付宝的坑
Android在集成支付宝sdk的时候, 如果有安装支付宝,则启动支付宝app进行支付: 如果没有安装,则启动 H5PayActivity 进行支付. 记得在AndroidManifest里面配置: ...
- SQL初级第三课(下)
我们续用第三课(上)的表 辅助表 Student Course Score Teacher Sno ...
- 对于for的一些认识
/*▲ ▲▲ ▲▲▲ ▲▲▲▲ ▲▲▲▲▲ ▲▲▲▲▲▲*/例:如图用for嵌套打印一个三 ...
- sql跨电脑导数据
启用Ad Hoc Distributed Queries: reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigu ...
- [Leetcode|SQL] Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- 【BZOJ】2697: 特技飞行
题意 \(k(1 \le k \le 300)\)种物品,价值分别为\(c_i(0 \le c_i \le 1000)\).有\(n(1 \le n \le 1000)\)分钟,每分钟可以选择一个物品 ...
- 使用jQuery 的.on() 提交表单
示例: $(function () { $(document).on('submit', '#FormId', function () { var val = $("#Name") ...
- Excel中COUNTIFS函数统计词频个数出现次数
Excel中COUNTIFS函数统计词频个数出现次数 在Excel中经常需要实现如下需求:在某一列单元格中有不同的词语,有些词语相同,有的不同(如图1所示).需要统计Excel表格中每个词语出现的 ...
- JS中常遇到的浏览器兼容问题和解决方法【转】
今天整理了一下浏览器对JS的兼容问题,希望能给你们带来帮助,我没想到的地方请留言给我,我再加上: 常遇到的关于浏览器的宽高问题: //以下均可console.log()实验 var winW=docu ...
- Linux多线程实例练习 - pthread_cancel()
Linux多线程实例练习 - pthread_cancel 1.代码 xx_pthread_cancel.c #include <pthread.h> #include <stdio ...