在ASP gridview中更改第4行的颜色? [英] Change row number 4 color in ASP gridview ?

查看:34
本文介绍了在ASP gridview中更改第4行的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


请问我可以更改asp网格视图行的颜色

如果我需要更改第3行的行吗?





请任何想法:)

hi please haw can i change color for asp grid view row
if i need to change it for Row number 3 for example ?


please any idea :)

推荐答案

这取决于你想要改变的颜色。以下是代码中的几个示例

It depends which color you want to change. Here's a couple of examples in the code behind
GridView1.Rows[0].BackColor = Color.Purple;
GridView1.Rows[1].ForeColor = Color.Plum;
GridView1.Rows[2].BorderColor = Color.Red;





GridView1_DataBound事件将是放置此



The GridView1_DataBound event would be an appropriate place to put this


的合适位置除了上述解决方案。

也可以使用<$更改行颜色c $ c>样式属性

在调用 databind()方法之后或在$ $ c $内c> RowDatabound 事件

In addition to above solution.
the row color can also be changed using Style attributes
either after the calling the databind() method or inside the RowDatabound event
gv.DataSource = data;
gv.DataBind();
gv.Rows[4].BackColor = System.Drawing.Color.Red;







protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           if (e.Row.RowType == DataControlRowType.DataRow)
           {
               if (e.Row.RowIndex == 3) // zero based index
               {
                   e.Row.Style.Add("background-color", "green");
                   // (or)
                   e.Row.BackColor = System.Drawing.Color.Green;
               }
           }
       }


这篇关于在ASP gridview中更改第4行的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆