gridview repeater DataList 鼠标经过改变背景颜色
2010-12-02 20:18
633 查看
1.gridview
双击GridView的OnRowDataBound事件;
在后台的GridView1_RowDataBound()方法添加代码,最后代码如下所示:
2.repeater,DataList
DataList 和 Repeater 在 HTML界面表格<tr>标记中加入如下代码:
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>
双击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 鼠标经过改变背景颜色
- repeater单双行颜色不同,gridview repeater DataList 鼠标经过改变背景颜色
- gridview repeater DataList 鼠标经过改变背景颜色
- gridview repeater DataList 鼠标经过改变背景颜色
- GRIDVIEW 鼠标经过改变背景颜色
- Gridview,DataList,Repeater 鼠标经过时行颜色变换
- Gridview,DataList,Repeater 鼠标经过时行颜色变换
- 鼠标经过时改变背景颜色
- jquery动态添加的表格行鼠标经过时候改变行的背景颜色
- 鼠标经过行时改变行的背景颜色
- GridView扩展鼠标经过改变行的颜色
- gridview 鼠标经过改变颜色
- Gridview 和 DataList 鼠标经过时行颜色变换
- Gridview 和 DataList 鼠标经过时行颜色变换
- 鼠标经过时,改变表格行、列的背景颜色
- 鼠标经过时改变DIV背景颜色的三种途径
- 鼠标经过tr时,改变tr当前背景颜色
- asp.net GridView控件鼠标移动某行改变背景颜色(方法一)
- jQuery改变鼠标经过行的背景颜色
- asp.net GridView控件鼠标移动某行改变背景颜色(方法一)