正规早餐店加盟哪家好:gridview datalist行颜色渐变实例代码
来源:百度文库 编辑:中财网 时间:2024/05/05 02:06:37
gridview:
datalist/datagrid:
鼠标滑过颜色变化:
gridview:
代码
1 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
2 {
3 if (e.Row.RowType == DataControlRowType.DataRow)
4 {
5 e.Row.Attributes.Add("onmouseover", "currentColor=this.style.backgroundColor;this.style.backgroundColor='#E8D098'");
6 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentColor");
//单击行改变行背景颜色
e.Row.Attributes.Add("onclick","this.style.backgroundColor='颜色'; this.style.color='buttontext';this.style.cursor='default';");
7 }
8 }
datagird:
代码
1 protected void dgValueInfo_ItemDataBound(object sender, DataGridItemEventArgs e)
2 {
3 if (e.Item.ItemIndex != -1)
4 {
5 e.Item.Cells[0].Text = (e.Item.ItemIndex + 1).ToString();
6 ListItemType itemType = e.Item.ItemType;
7 if (itemType == ListItemType.Item)
8 {
9 e.Item.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#FBF9F9'");
10 e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=e");
11 }
12 }
13 }
datalist:
这个用类似上面的方式好像没有效果,所以可以考虑在页面去实现:
代码
1
2
3
4
5
6
7
8
9
10
11
12
14
15
16
17
或者有table,则在tr中实现....