Jump to content

ASP/DB Binding Table Row Colour based on Value


Recommended Posts

Posted

I have a table which currently alternates the row colour by using:

 

<%If (Repeat1__numRows Mod 2) Then%>

<%Else%>

<%End If%>

 

What I want to do is on the repeat region of the data, take 1 field value from the results and highlight that row using a specific colour i.e. Field value HOT = Highlight red, Field Value BLUE = Highlight blue

 

I've tried changing the Repeat1_ tO

 

If (recordsetname.Fields.Item("FieldName".Value) = "HOT"

 

but this causes an error on the page and it doesn't load.

 

Can anyone help me please?

Thanks.

Posted
Been a fair few years since I've done ASP, but you might want to use CSS

...

 

How does this coding fit in with the rest of the above please?

Posted

At the top within the

you'll want to put

.HOT {

background-color: #ccf;

}

 

Then rather than using if statements you can use class @Value. This will then style your table properties (rows) however you want them to be styled. Easier to update.

So for instance



...

@Value being the value of the data you want to look up.

 

- - - Updated - - -

 

you can add more to the styles for the different row styles you would like to use.

Posted

Not sure if that's a typo into here or actually in your code but I would expect:

[color=#333333]If (recordsetname.Fields.Item("FieldName".Value) = "HOT"

to read

[/color][color=#333333]If recordsetname.Fields.Item("FieldName").Value = "HOT" then

 

Although it's been yeeeears since I did ASP so it might be something else wrong.

 

Or (assuming that's how to access a field inside a recordset in ASP land) then as @ReadTheNetwork said,

"> and define a css class for each option[/color]
Posted

I cannot get either way to work basically I've got a Recordset which is pulling the data out, got a 2 row table with selected fields from the recordset, then as a repeat row.

 

The coding above has no effect .

The if recordset.fields.item was doesn't bomb the page out with an error but doesn't colour anything.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...