Sorry i’m new to .net and learning so this may be very simple.
I have a page with a html table on and am accessing it from code behind and changing what is displayed depending on values from a database, I have managed to change what text is displayed and the background color but i’m struggling to change either a rows or a cells font/fore color.
I know my code probably isn’t the most efficient way of doing this but as i said i am learning.
Thanks in advance – J.
'Iterate through the rows of the table.
For i = 0 To Table1.Rows.Count - 1
'Iterate through the cells of a row.
For j = 0 To Table1.Rows(i).Cells.Count - 1
If i = 0 Then
If (ds.Tables.Count > 0) And (ds.Tables(0).Rows.Count > 0) Then
Table1.Rows(i).BgColor = "#f4f4f4"
Else
Table1.Rows(i).BgColor = "#ffffff"
End If
If j = 0 Then
If (ds.Tables.Count > 0) And (ds.Tables(0).Rows.Count > 0) Then
Table1.Rows(i).Cells(j).InnerHtml = "Personal"
End If
End If
If j = 1 Then
If (ds.Tables.Count > 0) And (ds.Tables(0).Rows.Count > 0) Then
Table1.Rows(i).Cells(j).InnerHtml = "Section complete"
Else
Table1.Rows(i).Cells(j).InnerHtml = "Please complete this section"
End If
End If
If j = 2 Then
If (ds.Tables.Count > 0) And (ds.Tables(0).Rows.Count > 0) Then
Table1.Rows(i).Cells(j).InnerHtml = "Tick"
Else
Table1.Rows(i).Cells(j).InnerHtml = "X"
End If
End If
If j = 3 Then
If (ds.Tables.Count > 0) And (ds.Tables(0).Rows.Count > 0) Then
Table1.Rows(i).Cells(j).InnerHtml = "<input id=""Button1"" type=""button"" value=""Edit"" />"
Else
Table1.Rows(i).Cells(j).InnerHtml = "<input id=""Button1"" type=""button"" value=""Add"" />"
End If
End If
End If
You can use the CSSClass property of the Row element:
or you can set the Style attribute: