首先要定义一个样式,比如下面这个:
<style type="text/css">
.text
{
font-size
: 9px;
color
: #00f;
background
: 1px solid #cf0;
}
</style>

然后在aspx页面里,给Gridview添加OnRowDataBound="GridView1_RowDataBound",最后在cs页面写GridView1_RowDataBound的方法,在方法里给GridView相应行添加样式,代码如下:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
        
if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[
1].Attributes.Add("class""text");
            e.Row.Cells[2
].Attributes.Add("class""text");
            e.Row.Cells[
3].Attributes.Add("class""text");
        }
}

相关文章:

  • 2021-05-21
  • 2021-04-06
  • 2022-01-18
  • 2022-12-23
  • 2021-11-13
  • 2022-01-23
  • 2022-02-05
  • 2022-12-23
猜你喜欢
  • 2021-06-08
  • 2021-08-17
  • 2021-07-06
  • 2021-08-24
  • 2021-06-25
  • 2022-12-23
  • 2021-12-30
相关资源
相似解决方案