Solved

If condition in the string builder.

Posted on 2007-04-02
3
384 Views
Last Modified: 2008-01-09
Hello Experts,

I am building XML string to create a RDL file> Below is a piece of code from the same.
                writer.WriteStartElement("Style");
               writer.WriteElementString("TextDecoration", "Underline");
               writer.WriteElementString("FontWeight", "700");
               writer.WriteElementString("FontSize", "9pt");
               writer.WriteElementString("Color", "DarkSlateBlue");
               
               writer.WriteEndElement(); // Style

Currently the Color is hadcoded as DarkSlateBlue.
I need to write a condition for the color as shown as below
Iif(RowNumber("OrderDetail") Mod 2, "White", "AliceBlue")
How do I do this in the writer.WriteElementString("Color", "DarkSlateBlue"); something like this

0
Comment
Question by:rowmark
  • 2
3 Comments
 
LVL 25

Expert Comment

by:dstanley9
ID: 18836502
Are you using C# or VB?

C#:
writer.WriteElementString("Color", RowNumber("OrderDetail") % 2 == 1 ? "White" : "AliceBlue");

VB.NET:
writer.WriteElementString("Color", Iif(RowNumber("OrderDetail") Mod 2 = 1, "White", "AliceBlue"));
0
 

Author Comment

by:rowmark
ID: 18836760
I am getting an error saying RowNumber cannot exist in the current context and
Error      1      Unexpected character sequence. Expected a property name for the "<property> : <value>" declaration.      

How do I build a string that will return exactly like the one shown below:
=Iif(RowNumber("Table1") Mod 2, "White", "AliceBlue")

writer.WriteElementString("BackgroundColor", "=Iif(RowNumber('Table1') Mod 2, 'White', 'AliceBlue')");

Instead of single quote for Table1 and White and AliceBlue if we make them double quotes it will work.

Pls help
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 500 total points
ID: 18836796
OK I'm with you now.  In C# you need to escape the double quotes:

writer.WriteElementString("BackgroundColor", "=Iif(RowNumber(\"Table1\") Mod 2, \"'White\", \"'AliceBlue\")");

In VB, do the same thing woth two double quotes ("") instead of slash-quote.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now