Click here to Skip to main content
15,885,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How change a Cell color on DataView based on a Field that
is not shown in the DataView.
I'm using DataSource.

Thank you.
Posted
Updated 10-Aug-11 10:59am
v2
Comments
Alex Perepletov 11-Aug-11 1:12am    
Is it WinForms DataGridView? In DataGridView one would wire to the CellPainting event. In the event handler, one would get a row from DataSource at index e.RowIndex, and set e.CellStyle.BackColor accordingly.
TheCodeVB 11-Aug-11 15:48pm    
Is DataView in WebForm c#

1 solution

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

VB
'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) was the second column in the datagrid

so for a guess your code maybe something like
VB
'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
 
Share this answer
 
Comments
TheCodeVB 11-Aug-11 15:50pm    
You're reading Values from de Cell but I need to read a Value from SqlDataSource. This value is not shown in DataView.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900