-1
在一個Visual Basic WEB APPLICATION程序中顯示2列,多列表的問題在左列下方,右欄,我如何設置特定單元格或整行的背景顏色? (這就是我會表示選中)如何在Visual Basic的ASP.NET Web應用程序中更改表格單元格或行的背景顏色
在一個Visual Basic WEB APPLICATION程序中顯示2列,多列表的問題在左列下方,右欄,我如何設置特定單元格或整行的背景顏色? (這就是我會表示選中)如何在Visual Basic的ASP.NET Web應用程序中更改表格單元格或行的背景顏色
<table>
<tr>
<th>Column1</th>
<th>Column2</th>
</tr>
<tr>
<td style="background-color:gray;">Question 1</td>
<td>Answer 1</td>
</tr>
<tr>
<td>Question 2</td>
<td>Answer 2</td>
</tr>
<tr style="background-color:yellow;">
<td>Question 3</td>
<td>Answer 4</td>
</tr>
</table>
好吧,如果你想要做動態,那麼你可以這樣做:
假設在GridView ID = gridview1
Protected Sub GridView_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim question, answer As String
question = e.Row.Cells(0).Text
answer = e.Row.Cells(1).Text
If question = "Will this work or whatever else you wanan check?"
e.Row.Cells(0).BackColor = Drawing.Color.Red
End If
'You could then add as many if statements as you need to handle
'different questions. For answers, you would just change the index to 1. Assuming it's
'column 1 in your gridview.
End If
End Sub