473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Formatting a row in a grid

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("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,

Andy
Nov 17 '05 #1
0 984

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
5
by: Jeff Cook | last post by:
Hi I have a DataGrid that I am using to display a .xml file (that has a schema in a .xsd), like this:- ds.ReadXmlSchema(sDataPath + "Data.xsd"); ds.ReadXml(sDataPath + "Data.xml",...
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
2
by: Dave | last post by:
I am converting an ASP Classic web site to an ASP.NET application and have some real basic formatting or design questions. (The classic ASP site has both code (forms) and content pages.) 1.When...
3
by: Roy | last post by:
Here's my problem for the curious consumption of the group mind... I have an embedded datagrid which works fine. The child grid is nested within the parent using a templatecolumn tag. Using the TR...
0
by: d pak | last post by:
Here is a snippit which replicates my issue. I have a datagrid which contains an input textbox on each row, binded on the serverside. However it seems that when I perform a postback to refresh teh...
2
by: RCM | last post by:
I have a very simple gridview that is working fine. My real data is more complicated, but for purposes of my question imagine a grid display that looks like: Audi red heavy Audi blue medium...
6
by: Brian Schwartz | last post by:
Quick question related to Visual Studio's automatic code formatting. Often I like to write my variable declarations with spacing to line them up, like this (not sure if this spacing will come out...
4
by: Keith G Hicks | last post by:
I have a gridview (asp.net 2.0) where I'm trying to format rows based on a NON VISIBLE column. It doesn't seem to work. When column 0 below is visible, the row is formatted as expected but when...
3
by: Cdude | last post by:
I am using this code at the moment to format the column this.itemsDataGrid.Columns.DefaultCellStyle.Format = "c"; but i get the error "Object reference not set to an instance of an object. "...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.