Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

If condition in the string builder.

Posted on 2007-04-02
3
Medium Priority
?
434 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

609 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