<style type="text/css">
.text{
font-size: 9px;
color: #00f;
background: 1px solid #cf0;
}
</style>
.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");
}
}
{
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");
}
}