This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
In my report, i have a TextBox which retrieve the result from the database.I am using this code :
=Fields!Category.Value.ToString().Trim(
But i am encountering a problem,wherein,when the value contains '&' (ex. Jog & Hop)
the result became Jog&Hop.
What could be wrong with my trim???
Thanks!!
Looks like the space in-between (before and after &) is being taken out and hence you might be seeing Jog&Hop or JogJog&Hop(HTML equivalent)
C# Example, you may want to use Replace to get at spaces surrounding "&"string test = "Jog & Hop"; Console.WriteLine(test.Trim(' ').TrimEnd(',').TrimStart(',')); Console.WriteLine(test.Trim(' ').TrimEnd(',').TrimStart(',').Replace(" ",""));
C# Example, you may want to use Replace to get at spaces surrounding "&"
string test = "Jog & Hop"; Console.WriteLine(test.Trim(' ').TrimEnd(',').TrimStart(',')); Console.WriteLine(test.Trim(' ').TrimEnd(',').TrimStart(',').Replace(" ",""));