This topic is locked
[SOLVED]

 Conditional Row Color

8/21/2014 1:32:26 PM
ASPRunnerPro General questions
author

I am using ASPRunner Pro Enterprise Edition Version 8.1 Build 21342.
I have searched and read the ASPRunner manual and have search the forum for what I want. I have a table with a field "Company". Depending on the Company I want the row to display a certain color.
For Example if the Company is Sears I want the row to show blue....if the company is Walmart I want the row to show Green.
I see that the best place for this to occur is to place the coding in the Event section under the List After Record Processed area.
I can successfully change the color of all rows with this code:
row("rowstyle")="style='background:yellow'"
But when I try to place any conditional formatting using an example from one of the forum searches such as:
if ($data["Company"]=="Walmart")

$row["rowstyle"]='style="background:blue"';

else

$row["rowstyle"]='style="background:pink"';
it gives a "Microsoft VBScript compliation error: Invalid character in line 2".
It does not matter what code I put in the function area, if there is a second line it always gives this error. If I use the one line to change all rows color it works fine.
I have read on the reasons and there were two main ones. I have checked for the main reasons and have physically retyped the statement in the format window.

It is always the same error.
Any help would be appreciated.

Joe

admin 8/21/2014

You are trying to use PHP examples in ASPRunnerPro. Needless to say it won't work.
Check examples provided in this article:

http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/

M
Maurits 8/22/2014



I am using ASPRunner Pro Enterprise Edition Version 8.1 Build 21342.
I have searched and read the ASPRunner manual and have search the forum for what I want. I have a table with a field "Company". Depending on the Company I want the row to display a certain color.
For Example if the Company is Sears I want the row to show blue....if the company is Walmart I want the row to show Green.
I see that the best place for this to occur is to place the coding in the Event section under the List After Record Processed area.
I can successfully change the color of all rows with this code:
row("rowstyle")="style='background:yellow'"
But when I try to place any conditional formatting using an example from one of the forum searches such as:
if ($data["Company"]=="Walmart")

$row["rowstyle"]='style="background:blue"';

else

$row["rowstyle"]='style="background:pink"';
it gives a "Microsoft VBScript compliation error: Invalid character in line 2".
It does not matter what code I put in the function area, if there is a second line it always gives this error. If I use the one line to change all rows color it works fine.
I have read on the reasons and there were two main ones. I have checked for the main reasons and have physically retyped the statement in the format window.

It is always the same error.
Any help would be appreciated.

Joe


Try deleting the character ; at the end of the line

1312 8/22/2014



Try deleting the character ; at the end of the line


Thank you both for your reply. I did try removing the ; with no success. Admin I feel your article will lead to my success, I will work through it.
Joe

M
Maurits 8/22/2014

It looks to me you confuse PHP with ASP
ASP should be:

if data("Profitability") < 0 then

row("rowstyle")="style='background:yellow'"

end if
PHP:

if ($data["Profitability"] < 0)

$row["rowstyle"]='style="background:yellow"';

1312 8/23/2014



It looks to me you confuse PHP with ASP
ASP should be:

if data("Profitability") < 0 then

row("rowstyle")="style='background:yellow'"

end if
PHP:

if ($data["Profitability"] < 0)

$row["rowstyle"]='style="background:yellow"';


Thank you Maurits for your input. I have made progress, to a point.
The code I am using:
If data("Company") = Lowes then

row("rowstyle")="style='background:yellow'"

Elseif data("Company")= Sears then

row("rowstyle")="style='background:green'"

End if
Works for the first data item "Lowes" but when I add another data item "Sears" it only highlights Lowes.
Any suggestions?

Thanks

Joe

admin 8/24/2014

Joe,
you need to learn the basics of ASP. In ASP strings must be quoted:

If data("Company") = "Lowes" then

row("rowstyle")="style='background:yellow'"

Elseif data("Company")= "Sears" then

row("rowstyle")="style='background:green'"

End if
1312 8/24/2014



Joe,
you need to learn the basics of ASP. In ASP strings must be quoted:

If data("Company") = "Lowes" then

row("rowstyle")="style='background:yellow'"

Elseif data("Company")= "Sears" then

row("rowstyle")="style='background:green'"

End if



Yes I am doing that as fast as I can. Your statement worked as it should and I thank you.
I had previously used the following before my last post, along with many other versions, with no success. I was close but not where I should have been. I used:
If data("Company").Equals("Lowes") then row("rowstyle")="style='background:yellow'" ElseIf data("Company").Equals("Sears") then row("rowstyle")="style='background:blue'" end if
I didn't think to remove the () and . for it to work properly. I do apologize for not trying harder.
Joe

G
gonzalosb 8/24/2014

hi Tman,

try to use separated " IF " functions without " ELSE ".

you can do it in 2 ways:



If data("Company") = "Lowes" then

row("rowstyle")="style='background:yellow'"

end if

If data("Company")= "Sears" then

row("rowstyle")="style='background:green'"

End if


or



If data("Company") = "Lowes" then

row("rowstyle")="style='background:yellow'"
If data("Company")= "Sears" then

row("rowstyle")="style='background:green'"
End if

End if


remember for each " IF " you need to close with " END IF "
replace " .ecuals " for " = "
hope this helps, let me know howit works.

1312 8/24/2014



hi Tman,

try to use separated " IF " functions without " ELSE ".

you can do it in 2 ways:



If data("Company") = "Lowes" then

row("rowstyle")="style='background:yellow'"

end if

If data("Company")= "Sears" then

row("rowstyle")="style='background:green'"

End if


or



If data("Company") = "Lowes" then

row("rowstyle")="style='background:yellow'"
If data("Company")= "Sears" then

row("rowstyle")="style='background:green'"
End if

End if


remember for each " IF " you need to close with " END IF "
replace " .ecuals " for " = "
hope this helps, let me know howit works.


Yes Sir both of your statements worked as they should and gave the desired results.
I appreciate your assistance.

G
gonzalosb 8/25/2014

Glad I can help