對不起,我是.net和學習的新手,所以這可能非常簡單。HTML表格forecolor後面的ASP.NET VB代碼
我有一個頁面上的HTML表,並從後面的代碼訪問它,並根據數據庫中的值更改顯示內容,我設法更改顯示的文本和背景顏色,但我很掙扎更改行或單元格字體/前景色。
我知道我的代碼可能不是這樣做的最有效的方式,但正如我說我正在學習。
在此先感謝 - 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
謝謝你們,他們都做到了。 – JBoom 2011-02-03 11:56:10