Last post Oct 31, 2011 01:01 PM by billcrawley
Oct 28, 2011 04:10 AM|billcrawley|LINK
I have intorduced a report (rdlc) doc into my Web App (VS2010). and its bound by an ObjectdataSource. One of the columns has a plathora of data and as such I have to use string manipulation in the expression on the report to obtain the value that I want
to display. This all works fine if the data can actully be found in the bound column. But if the data cannot be found (could be optional when the data was built), the report falls over in a heap.
A typical expression I have ont he report is:
= Mid(Fields!ClientData.Value,InStr(Fields!ClientData.Value,"Business Event:"),InStr(Fields!ClientData.Value,"Policy:")-InStr(Fields!ClientData.Value,"Business Event:"))
I need a way of testing that these values can be found in the string before attempting the above. How do I do this in the expression given that it looks as though I cannot use a simple 'if' statement and of course the inline 'iif' wants to evaluate the whole
Oct 31, 2011 02:31 AM|Phinehas|LINK
You can try to use if statement for testing the length of your fields.
IIF(Len(Fields!xxx.value) = 0, your expression, "")
Oct 31, 2011 01:01 PM|billcrawley|LINK
Trouble with IIf is that it wants to evaluate the whole expression first. Before I can test the len I need to chop the string into it's constituent parts. and because the test mayy or may not exist, that's where the problem is.
I gave up trying to use the subset of VBA built into the reports and instead wrote my own Datasource in C# and pointed to that. It meant that I could use the full power of C# to perform my testing before the data even reached the report. This has solved
my problem. It seems that connectiong directly through from the Report is only any good when you can gaurentee that the data will always exist.