CVer Learns ML.

I am Shicai, interested in Computer Vision, Pattern Recognition, Machine Learning and Web Design. @Southeast University, Nanjing 211189, PR China

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
首先要定义一个样式,比如下面这个:
<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");
        }
}
posted on 2007-12-14 16:58  Shicai Yang  阅读(516)  评论(0编辑  收藏  举报