Formatting a row in a grid

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top