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

GridView分页如何使前5条数据标题红色显示
GridView分页如何使前5条数据标题红色显示,其它数据黑色显示

------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0 && e.Row.RowIndex <= 4)
{
e.Row.Cells[1].Style.Value = "color:red";//假如第二列显示的是标题
}
else
{
e.Row.Cells[1].Style.Value = "color:black";
}
}
------解决方案--------------------
aspx:
OnRowDataBound="GridView1_RowDataBound"


cs:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 

if (e.Row.RowIndex >= 0 && e.Row.RowIndex <= 4) 

e.Row.Cells[1].Style.Value = "color:red";//假如第二列显示的是标题 
}
------解决方案--------------------
C# code

   for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            if (i >= 0 && i < 5)
            {
                GridView1.Rows[i].BackColor = Color.Pink;
            }
            else 
            {
                GridView1.Rows[i].BackColor = Color.Black;
            }
        }