-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