xml nillable date

Stimulsoft Reports.NET discussion
Post Reply
jmiller
Posts: 91
Joined: Mon Sep 20, 2010 12:18 pm

xml nillable date

Post 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.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

xml nillable date

Post by Ivan »

Hello,

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

Thank you.
Attachments
1143.ShowInsteadNullValues.gif
1143.ShowInsteadNullValues.gif (23.06 KiB) Viewed 4045 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

xml nillable date

Post 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.
Attachments
1144.text editor.png
1144.text editor.png (63.79 KiB) Viewed 4043 times
jmiller
Posts: 91
Joined: Mon Sep 20, 2010 12:18 pm

xml nillable date

Post 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();
jmiller
Posts: 91
Joined: Mon Sep 20, 2010 12:18 pm

xml nillable date

Post 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.
Attachments
1150.SampleData2.mrt
(8.21 KiB) Downloaded 309 times
1149.SampleData.xsd
(790 Bytes) Downloaded 346 times
1148.SampleData.xml
(657 Bytes) Downloaded 417 times
1147.Program.cs
(930 Bytes) Downloaded 411 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

xml nillable date

Post 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.
jmiller
Posts: 91
Joined: Mon Sep 20, 2010 12:18 pm

xml nillable date

Post 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"].
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

xml nillable date

Post 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.
Post Reply