我正试图改变
backcolor
在.net中
GridView
当满足一定条件时。这应该相当简单,但颜色变化不会发生。检查呈现的HTML在受影响的行中显示出完全不同的内容,即使链接上的文本发生了预期的更改。
有一个默认的主题集
gridviews
我以前也没用过。这是为了阻止我动态地更改行的颜色,还是我遗漏了其他内容?
我正在使用.NET 3.5并在代码中包含以下内容:
Protected Sub gvPrevious_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gvPrevious.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If currentCorrespondence.IsRetired Then //custom object, returning as expected
Dim link As LinkButton = DirectCast(e.Row.Controls(4).Controls(2), LinkButton)
link.Text = "Reinstate" //default is "retire" - GV renders this as expected
e.Row.BackColor = Drawing.Color.IndianRed //might as well not be here
End If
End If
End Sub
从上面的代码中,当我进入浏览器并查看源代码时,我希望看到
<tr style="background-color: #CD5C5C;">
对于受影响的行。相反,我看到
<tr>
和
<tr class="AlternateRowStyle">
(如适用)。我完全看不出
BackColor
属性更改。
我也尝试过使用
e.Row.CssClass
结果相同。