DataView根据数据源项目值更改单元格颜色. [英] DataView Change Cell Color based on DataSource Item Value.

查看:326
本文介绍了DataView根据数据源项目值更改单元格颜色.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据一个字段更改DataView上的单元格颜色
未显示在DataView中.
我正在使用数据源.

谢谢.

How change a Cell color on DataView based on a Field that
is not shown in the DataView.
I''m using DataSource.

Thank you.

推荐答案

hi
我尝试执行此操作,但是当单元格为空白且这是我使用的代码时,首先必须执行
hi
i attempted to do this but when the cell was blank and this is the code i used, first i had to do
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound



然后我必须添加代码



then i had to add the code

'change the colour of the cells if cell value is null or "&ndsp;"
  If (e.Row.Cells(1).Text = "" Or e.Row.Cells(1).Text = " ") Then
      e.Row.Cells(1).BackColor = System.Drawing.Color.Salmon
      importButtonEnabled = False
  End If



row.cell(1)是datagrid中的第二列

因此,您的代码可能有点像



row.cell(1) was the second column in the datagrid

so for a guess your code maybe something like

'change the colour of the cells if cell value is null or "&ndsp;"
  If (e.Row.Cells(1).Text = "certain value") Then
      e.Row.Cells(1).BackColor = System.Drawing.Color.colour of your choice      importButtonEnabled = False
  End If



希望这对一些帮助



hope this helps some what


这篇关于DataView根据数据源项目值更改单元格颜色.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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