动态填充的gridview的文本颜色更改 [英] Text Colour Change Of Dynamically populated gridview
本文介绍了动态填充的gridview的文本颜色更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从数据库中填充了动态网格视图,并将单元格文本设置为ON和OFF.我希望关闭文字应显示为红色"颜色.
网格行是根据雇员数生成的,列是数据库中特定月份中的天数.
I have populated a dynamic grid view from database with Cell text as ON and OFF. I want that off text should appear in "Red" Colour.
Grid rows are generated as no.of employees and columns are days in a particular month from database.
推荐答案
使用RowDataBound通常是最好的方法.这是一个快速示例,该示例根据CheckBoxField的状态更改行颜色.
Using RowDataBound is frequently the best way. Here''s a quick example that changes the row color based on the status of a CheckBoxField.
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If (e.Row.RowType = DataControlRowType.DataRow) Then
Dim cb As CheckBox = CType(e.Row.Cells(1).Controls(0), CheckBox)
If (cb.Checked = False) Then
e.Row.BackColor = Drawing.Color.LightYellow
e.Row.Cells(0).ForeColor = Drawing.Color.Red
Else
e.Row.ForeColor = Drawing.Color.Blue
cb.Enabled = True
End If
End If
End Sub
HTH
HTH
这篇关于动态填充的gridview的文本颜色更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文