c#


How Do I Make DateTime Not Required?


I've got this model for an app that tracks our migration status for users. If they haven't been migrated, there's no migration date. So how can they leave that field blank? It's not annotated as required yet validation fails as if it is required. I cannot seem to set it to null either. How does one get around this problem?
[Display(Name = "Migrated?")]
public bool migrated { get; set; }
[Display(Name = "Date Migrated")]
public DateTime migrationdate { get; set; }
Use a nullable type
[Display(Name = "Migrated?")]
public bool migrated { get; set; }
[Display(Name = "Date Migrated")]
public DateTime? migrationdate { get; set; }

Related Links

protobuf-net : v2 deserialize v1 objects with inheritance
Getting data on ListView Select event and setting it in a div in C#
c# Oledb add list of parameters in a foreach loop
dotnet ef not works with ef tools 1.1.0-preview4-final
Check permission of a PDF using itext [duplicate]
Is there an event fired when WebBrowser content is redrawn?
How can I filter a DataTable without brute-forcing it?
Creating objects using an older version of Google Protobuf
WPF Combo box not calling setter method when item changed
Entity RemoveRange delete all rows
zip is not working in the same way on 4.2 to 6.0
Twilio Error - 12300 - Invalid Content Type only sometimes
Range validation in the Form Designer's PropertyGrid of a shadowed property
SaveChanges without AcceptChanges
AppHarbor c# 4.6.1 higher version than exists in current target framework
MonoGame - RenderTarget2D drawn below sprites and in the wrong location

Categories

HOME
redux
macros
process
skypedeveloper
aggregate-functions
liquidsoap
python-3.4
markdown
rtc
cracking
apache-httpclient-4.x
facebook-sharer
expo
swift3.1
smooth-scrolling
legend-properties
passbook
gpo
glibc
turn.js
bug-reporting
multipart
proof-general
bytebuffer
r-factor
choco
visual-prolog
node-soap
repeat
border-layout
redhat-brms
ui-grid
azure-web-roles
collation
java-5
codepen
anonymous-function
dcom
google-cloud-shell
cloudconvert
standard-error
perldoc
liferay-ide
directinput
rowname
cosign-api
airwatch
objectify
gdi
avi
google-finance-api
clear
skscene
jsoncpp
properties-file
dpkt
clearquest
skview
maven-archetype
xmla
applinks
aiff
javadb
nsnotificationcenter
powershell-v1.0
behance-api
enquire.js
git-subtree
acrofields
raddatepicker
proj4
wordbreaker
bash4
scriptmanager
clgeocoder
lightopenid
xhtmlrenderer
designated-initializer
norton
onunload
chars
jquery-attributes
software-update
moores-law

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App