Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Formatting a row in a grid

Thread Tools

Formatting a row in a grid

Andrew Kidd
Posts: n/a

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"
strFontColour = "#000000"
End If %>
<td width="15%"><font color="<%=strFontColour%>"><%=rs_main.fields("Memb erName")%></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,

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grid within a Grid ItemDataBound event problem Girish ASP .Net 4 07-19-2005 01:17 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Row / Column gets much bigger when editing a row in grid Bazza Formez ASP .Net 4 12-09-2004 11:03 PM
data grid conditional row formatting Brian Henry ASP .Net 2 07-08-2004 04:10 PM
How to find grid's row that matches row in dataset IK ASP .Net Datagrid Control 0 09-15-2003 05:40 PM