网格视图的功能性? [英] grid view functunality ?

查看:88
本文介绍了网格视图的功能性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格面,其中有两列-人的姓名和薪水.现在我要突出显示人薪超过特定金额的特定单元格.如何实现它?

i have a grid veiew which has two columns - name and salary of person .Now i want to highlight particular cell where persons salary exceeds a particular amount .How to implement it ?

推荐答案

您可以像这样使用GridViewRowDataBound Event:
You can use GridView''s RowDataBound Event like this:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow )
            {
              
                double salary=0.0;
               salary= double.parse(e.Row.Cells[1].Text;
                if (salary>=5000)
                {
                    //highlight row or cell here
                    e.Row.Cells[1].BackColor=System.Drawing.Color.Red ;
                    //e.Row.BackColor=System.Drawing.Color.Red ;
                 
                }
            }
        }


使用OnRowDataBound事件.在这种情况下,您仍然可以访问数据,并且可以检查工资值.在这种情况下,可以更改行或单元格颜色.
use the OnRowDataBound event. In that event you still have access to the data and you can check the value of salary. In that case the row or cell Color can be changed.


http://forums.asp.net/t/1025496.aspx/1 [ ^ ]
http://stackoverflow.com/questions/661670/how-to-在条件视图中实现条件条件 [ ^ ]

Google [ ^ ]用于条件格式.
http://forums.asp.net/t/1025496.aspx/1[^]
http://stackoverflow.com/questions/661670/how-to-implement-conditional-formatting-in-a-gridview[^]

Google[^] for conditional formatting.


这篇关于网格视图的功能性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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