protected void GridMain_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //取出times=0,标注没读的颜色为红色;                if ("recnote" == msgbox )
                {
                    int times = Convert.ToInt32(e.Row.Cells[8].Text);
                    if (times == 0)                    //我用以下两句话都实现不了,为什么???怎么实现呢???
                    e.Row.Cells[3].Attributes.Add("style", "color:red");    //字体改变颜色;
                    e.Row.Cells[3].Style.Add("color", "red");   ////字体改变颜色;
                      
                   
                                     }
}

解决方案 »

  1.   


     e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F4E088';");
                    //当鼠标移开时还原背景色
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
      

  2.   


    e.Row.Cells[0].ForeColor = Color.Red;
      

  3.   

    protected void grdtalk_RowDataBound(object sender, GridViewRowEventArgs e)
        {        if (e.Row.RowIndex !=-1&&e.Row.RowIndex<5)
            {
                //e.Row.BackColor = Color.Red;//符合条件的数据行显示不同的颜色        }
              if (e.Row.RowIndex != -1)
              {
                  HyperLink hk = e.Row.Cells[2].FindControl("HyperLink1") as HyperLink;
                  string title = hk.Text;
                  if (e.Row.RowIndex < 5)
                  {
                      hk.Text = title.Replace(title, title+ "【置顶】");
                      if (title.Length > 10)
                      {
                          hk.Text = title.Replace(title, title.Substring(0, 10) + "..." + "【置顶】");
                      }
                      else
                      {
                          if (title.Length > 10)
                          {
                              hk.Text = title.Replace(title, title.Substring(0, 10) + "...");
                          }
                      }
                  }
                  else
                  {
                      if (title.Length > 10)
                      {
                          hk.Text = title.Replace(title, title.Substring(0, 10) + "...");
                      }
                  }
              }
        }
      

  4.   

    楼主的e.Row.Cells[3].Attributes.Add("style", "color:red");    //字体改变颜色;
    和楼上的
    e.Row.Cells[0].ForeColor = System.Drawing.Color.Red;都是可以的!!
    如果没效果是其它地方有误!!