A
Andrew Kidd
Hi,
I've decided to bite the bullet and try my hand at this .Net stuff & doing OK so far, but I can't seem to work this last problem out.
I need to change the font colour of a row depending on a value in the underlying recordset. In 'classic asp' I do something like this:
..
..
..
If rs_main.Fields("Flag") = True Then
strFontColour = "#FF0000"
Else
strFontColour = "#000000"
End If %>
..
..
..
<td width="15%"><font color="<%=strFontColour%>"><%=rs_main.fields("MemberName")%></font></td>
In ASP.Net I've got something like this:
Private Sub grdMembers_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdMembers.ItemCreated
If e.Item.ItemType = ListItemType.Item And e.Item.Cells(2).Text = "True" Then
e.Item.ForeColor = System.Drawing.Color.Red
End If
End Sub
....But it's not working. Also, in the 'classic asp' approach I don't output the field into the table, just have it in the query so that I can test for it. Now, if it's in the DataReader it's going to show up & I don't want it to.
Where have I gone wrong in the code & how do I not show a field in the grid for the value that I'm testing for?
Thanks in advance,
Andy
I've decided to bite the bullet and try my hand at this .Net stuff & doing OK so far, but I can't seem to work this last problem out.
I need to change the font colour of a row depending on a value in the underlying recordset. In 'classic asp' I do something like this:
..
..
..
If rs_main.Fields("Flag") = True Then
strFontColour = "#FF0000"
Else
strFontColour = "#000000"
End If %>
..
..
..
<td width="15%"><font color="<%=strFontColour%>"><%=rs_main.fields("MemberName")%></font></td>
In ASP.Net I've got something like this:
Private Sub grdMembers_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdMembers.ItemCreated
If e.Item.ItemType = ListItemType.Item And e.Item.Cells(2).Text = "True" Then
e.Item.ForeColor = System.Drawing.Color.Red
End If
End Sub
....But it's not working. Also, in the 'classic asp' approach I don't output the field into the table, just have it in the query so that I can test for it. Now, if it's in the DataReader it's going to show up & I don't want it to.
Where have I gone wrong in the code & how do I not show a field in the grid for the value that I'm testing for?
Thanks in advance,
Andy