Page 1 of 1

xml nillable date

Posted: Tue Jul 12, 2011 1:18 pm
by jmiller
How can I test for a nil date in xml data in an expression? I have a report with dates. The dates can be nil. On the report I want to show "----" whenever a date is nil. I've tried various things but could not get it to work. Stimulsoft reads in the xml data fine. It even shows empty space for those nil dates. I just want to change the empty space to "----" or some other text.

xml nillable date

Posted: Wed Jul 13, 2011 2:53 am
by Ivan
Hello,

You can use, for example, the ShowInsteadNullValues property on the DataColumn tab of the TextEditor.

Thank you.

xml nillable date

Posted: Wed Jul 13, 2011 3:13 am
by HighAley
Hello.
jmiller wrote:How can I test for a nil date in xml data in an expression? I have a report with dates. The dates can be nil. On the report I want to show "----" whenever a date is nil. I've tried various things but could not get it to work. Stimulsoft reads in the xml data fine. It even shows empty space for those nil dates. I just want to change the empty space to "----" or some other text.
You can set "Show instead null values" in Text editor.
Or you can write such expression:

Code: Select all

{(Orders["ShippedDate"] == DBNull.Value ? "---" : Orders["ShippedDate"])}
Thank you.

xml nillable date

Posted: Wed Jul 13, 2011 5:04 am
by jmiller
I still can't get it to work. I selected "Absent" in the drop-down and my report still shows a blank. I also tried the == DBNull.Value and that also shows a blank. Could it be because I am defining the data in code instead of the designer.
System.Data.DataSet ds = new System.Data.DataSet();

ds.ReadXmlSchema("Data\\InstallmentBill.xsd");
ds.ReadXml("Data\\SampleInstallmentBillData.xml");

ds.DataSetName = "SampleData";

Stimulsoft.Report.StiReport rpt = new Stimulsoft.Report.StiReport();

rpt.Load("Data\\InstallmentBill.mrt");

rpt.RegData(ds);
rpt.Dictionary.Synchronize();
rpt.Compile();

xml nillable date

Posted: Wed Jul 13, 2011 6:02 am
by jmiller
I am uploading a full set of files to show my problem. Could the problem have to do with the .mrt not having any data sources defined? Here is what I did:
- Created the Visual Studio solution
- Created the sample xml and the xsd
- Created a new report mrt and loading the xml/xsd as a data source
- After I created the mrt elements I deleted the xml data source since I will be using code to define it.
- Wrote the code in my VS solution to register the xml/xsd

As you can see from the pdf provided, my 'nil' dates remain blank.

xml nillable date

Posted: Wed Jul 13, 2011 8:31 am
by HighAley
Hello.
jmiller wrote:I am uploading a full set of files to show my problem. Could the problem have to do with the .mrt not having any data sources defined? Here is what I did:
- Created the Visual Studio solution
- Created the sample xml and the xsd
- Created a new report mrt and loading the xml/xsd as a data source
- After I created the mrt elements I deleted the xml data source since I will be using code to define it.
- Wrote the code in my VS solution to register the xml/xsd

As you can see from the pdf provided, my 'nil' dates remain blank.
If you set the ShowInsteadNullValues property on the DataColumn tab of the TextEditor and then go to Expression tab this property will not work. This problem have been added to our to-do list. Now for correcting this problem please open Text Editor in Data Column tab and press OK.

Also if you use expressions you can use one of next expressions:

Code: Select all

{IIF(DataRecord["DueDate"] == DBNull.Value,"Absent",DataRecord["DueDate"])}

Code: Select all

{DataRecord["DueDate"] == DBNull.Value ? "Absent" : DataRecord["DueDate"]}
For formatting data you can set Text Format property.

Please see attached report template.

Thank you.

xml nillable date

Posted: Wed Jul 13, 2011 9:36 am
by jmiller
I was able to get it to work with the expression code you suggested. What I was doing in my expression before was:
{IIF(DataRecord.DueDate == DBNull.Value,"Absent",DataRecord.DueDate)}

This did not work, but once I changed it to DataRecord["DueDate"] then all is fine. I'm guessing your generated property for DueDate differs from ["DueDate"].

xml nillable date

Posted: Thu Jul 14, 2011 1:21 am
by HighAley
Hello.
jmiller wrote:I was able to get it to work with the expression code you suggested. What I was doing in my expression before was:
{IIF(DataRecord.DueDate == DBNull.Value,"Absent",DataRecord.DueDate)}

This did not work, but once I changed it to DataRecord["DueDate"] then all is fine. I'm guessing your generated property for DueDate differs from ["DueDate"].
About the differences between DataRecord.DueDate and DataRecord["DueDate"] you can read in Stimulsoft Reports Universal User Manual in section 3.1.6.
It should be remembered that all the values in data sources are typed. This means that all data items
are dynamically converted to the type that is specified in the options column which helps to accelerate
the development of reports. However, if you need to get data from a column without conversion you will
need to specify the data source directly. For example, in C#:

Code: Select all

{Products["ProductName"]}
We are always glad to help you.

Thank you.