开发者

SSRS function returns #Error if value of field is null

开发者 https://www.devze.com 2022-12-24 06:53 出处:网络
Thanks in advance for any and all assistance. My code is: Public Function StripHTML(value As String) As String

Thanks in advance for any and all assistance.

My code is:

Public Function StripHTML(value As String) As String
Return System.Text.RegularExpressions.Regex.Replace(value, "<(.|\n)*?>", "")
End Function

Then I call the function from a textbox. This works great unless there are nulls in the dataset. I tried to compensate for the nulls, but the RDLC file generates an error message that it can't display the subreport.

Public Function StripHTML(value As String) As String
if isnothing(value) then return value 
else 
Return Syst开发者_Go百科em.Text.RegularExpressions.Regex.Replace(value, "<(.|\n)*?>", "")
end if 
End Function

I also tried to tell it to return " " if null.

I had no luck...

Any ideas? and thanks again.


Have you tried to set TextBox value to formula like this?

=iif(Fields!USER_TEST.Value is nothing,"-",StripHTML(Fields!USER_TEXT.Value))


Use nullable types to check for nulls, it's supported from .net version 2.0 & above.

ex:

Nullable<int> x = null;

if (x.HasValue) Console.WriteLine("x is {0}", x.Value);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号