用颜色填充一些行 [英] Filling some rows with colour

查看:69
本文介绍了用颜色填充一些行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我的Web应用程序中有一个Gridview控件.我想根据数据库中的值用红色突出显示一些行.

您能否提出一些解决此要求的解决方案.


在此先感谢.

Hello,

I have a Gridview Control in my Web Application.I want to highlight some rows with red colour based upon the values from database.

Can you suggest some solution to this requirement.


Thanks in advance.

推荐答案

请参见以下讨论:
http://forums.asp.net/p/1478345/3443644.aspx [ ^ ].

—SA
See this discussion:
http://forums.asp.net/p/1478345/3443644.aspx[^].

—SA


捕获RowDataBound事件,然后在此处放置逻辑

Capture the RowDataBound event and then place your logic here

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    // searching through the rows
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
            if(MyDatabaseCondtion()){
                e.Row.ForeColor = System.Drawing.Color.Red;
            }
    }
}



MyDatabaseCondition()方法将检查您所需的数据库条件.



The MyDatabaseCondition() method will check the database condition that you require.


尝试此链接

change-gridview-row-color-based-on-condition [ ^ ]
try this Link

change-gridview-row-color-based-on-condition[^]


这篇关于用颜色填充一些行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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