InfoPath 2010 - Date Picker problem when SetVal from CodeBehind

Recently we came across a problem in InfoPath 2010 DateTime Control. When we assign a value in code-behind, the text box is marked red and asking for a valid date. However the date was valid and when we type the same date, it accept the same date. The assignment was as follows in code behind which produces the error

MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:grpFeeDetails/my:dateDPO", NamespaceManager).SetValue(l_oDateTimeDateDPO.ToShortDateString());

Identified Problem
Basically the issue is with the format of the date. When we use ToShortDateString, then the format is not compatible with the InfoPath 2010 Date Format.

Resolution
To resolve this issue we used the following code

MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:txtDOB", NamespaceManager).SetValue(l_oDateTimeDOB.ToString("yyyy-MM-dd"));

The Important Point is this DateTime Format
l_oDateTimeDOB.ToString("yyyy-MM-dd")

Thanks to this post which help us to resolve this issue
InfoPath 2010 date and time picker control basics
http://www.bizsupportonline.net/infopath2010/infopath-2010-date-and-time-picker-control-basics.htm



Comments

  1. Thanks so much. Was in this exact prb and your solution worked, even 3 years later...:)

    ReplyDelete
  2. cloud managed switch, thousands of switch ports can be configured and monitored instantly over the web. Without needing a physical connection between switches, you can remotely configure them for access devices, assign voice VLANs, control PoE, and more, with just a few simple clicks and without on-site IT. By managing your network through the cloud you can provision remote sites, deploy network-wide configuration changes, and easily manage campus and distributed networks without IT training or dedicated staff.

    ReplyDelete

Post a Comment

Popular posts from this blog

Export Data from AX 2012 - using DIXF (Data Migration Framework)

The virtual path maps to another application, which is not allowed

Agile Management - TFS (Priority, Stack Rank and Severity)