Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Nullable System.DateTime in Web.Config (System.DateTime?)

Posted on 2014-01-06
4
Medium Priority
?
355 Views
Last Modified: 2014-08-07
I use the Stored Procedure Profile Provider in my ASP.NET web Project.

One of the values I need to store on the User Object is called PaymentDate. The datatype need to be DateTime, but since the value can be NULL I need the datatype it to be nullable.

In web.config I do like this:

<add name="PaymentDate" defaultValue="[null]" type="System.DateTime?" customProviderData="PaymentDate;DateTime;8" />

Open in new window


The code compile, and everything seems to work fine. But, when I open the web page I get a web.config error saying "Cannot load type System.DateTime?".

If I change "System.DateTime?" to "System.DateTime" it is not possible to set p.PaymentDate = null; (PaymentDate cannot be null).

So, how can I set the PaymentDate Type to be Nullable DateTime in web.config?
0
Comment
Question by:webressurs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39759940
Try this:

type="System.Nullable<System.DateTime>"

Open in new window

0
 
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 750 total points
ID: 39760468
Hi,

If kaufmed® solution works, then it's great.

Or you can use solution idea from link default value as null for a bool type in a profile provider for creating custom type.
0
 
LVL 1

Author Comment

by:webressurs
ID: 39761465
kaufm:

When writing type="System.Nullable<System.DateTime>" I get the error : Tag was not closed. When running the website I get the error: Configuration file is not well-formed XML.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 750 total points
ID: 39761838
Ah, forgot about the XML  : \

Let's try encoding the brackets:

type="System.Nullable&lt;System.DateTime&gt;"

Open in new window

0

Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question