Solved

If condition in the string builder.

Posted on 2007-04-02
3
371 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

762 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

9 Experts available now in Live!

Get 1:1 Help Now