日期:2014-05-18  浏览次数:20449 次

GridView隔行变色
会用js来控制table隔行变色,但是GridView不知道该怎么使用,不是鼠标指上的变色,而是各行编一个颜色,在CSS里面设置。

------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowIndex != -1)
{
if (e.Row.RowIndex % 2 != 0)
{
e.Row.Attributes.Add("onclick", "tog(this,'" + ApplicationAlert.pstrSecondColor + "')");
}
else
{
e.Row.Attributes.Add("onclick", "tog(this,'" + ApplicationAlert.pstrFirstColor + "')");
}
}
}
var tgs;
var tmp_background_val;
function tog(n,flags)
{

if (tgs){
tgs.style.background= tmp_background_val ;
}

n.style.background = '#D1D5E1' ;
tmp_background_val=flags;
tgs=n;

<AlternatingRowStyle CssClass="AlternatingRowStyle" />
------解决方案--------------------

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
 
if (e.Row.RowIndex != -1)
{
if (e.Row.RowIndex % 2 != 0)
{
e.Row.Attributes.Add("onclick", "tog(th……
[/Quote]

------解决方案--------------------
<RowStyle HorizontalAlign="Center" Height="30px" BackColor="White" Font-Size="14px" />
<AlternatingRowStyle BackColor="#E9F2FF" />