Gridview后台添加滑动效果
来源:岁月联盟
时间:2012-02-13
e.Row.RowType判断行的类型。
DataControlRowType选择行的类型
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.Header:
break;
case DataControlRowType.DataRow:
if (e.Row.RowIndex > -1)
{
// 奇数行
if (e.Row.RowIndex % 2 == 0)
{
e.Row.Attributes.Add
("onmouseover", "this.style.backgroundColor='#84AAEF';
this.style.color='white'");
e.Row.Attributes.Add
("onmouseout", "this.style.backgroundColor='#F7F6F3';
this.style.color='#333333'");
}
else www.2cto.com
{
e.Row.Attributes.Add
("onmouseover", "this.style.backgroundColor='#84AAEF';
this.style.color='white'");
e.Row.Attributes.Add
("onmouseout", "this.style.backgroundColor='#F7F6F3';
this.style.color='#333333'");
}
}
break;
}
}
摘自 徐越的专栏