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

How do I modify the rich text box control to simulate a code editor [closed]
How to insert Dot on Each character
UWP Xbox One difference between running in Retail to Dev Mode
MSBuild Build same DLL with two different projects
ILMerge.Merge: ERROR
Draw text centered in a ellipse/circle in winforms application
c# android bluetooth get socket from connected device
How to make a field auto populate in C# Visual Studio?
C# destructors and GC not really solving problems compared to C++ destructors
How to count occurences of a char in a big (5+ GBs) file using C#?
Confused about backgroundworker not stopping when expected
Ignore paging limit for Azure Mobile Service in a Universal app (UWP)
How to add object to list item in c#
Handling .NET events in COM / VBA
Reading specific XML parameter
c# charting - access from other thread exception

Categories

HOME
asp.net
logging
excel-formula
oop
msbuild
weblogic
ibm
download
zabbix
rethinkdb
promotions
normals
theory
elastalert
distinct
solidity
http-status-codes
oxid
opendaylight
sha1
dompdf
game-engine
facebook-marketing-api
alert
google-calendar-api3
accordion
turn.js
monad-transformers
include-path
bootstrap-accordion
ps
gsuite
suitescript
sqldependency
ds-5
ibm-bpm
spring-oauth2
unity3d-5
oracle-nosql
angularjs-resource
outlook-2010
byobu
azure-data-catalog
multivalue
photoshop-script
nservicebus6
programming-pearls
toggleclass
jigsaw
nsoperationqueue
audiorecord
archiva
producer-consumer
exchange-server-2007
page-flipping
pushwoosh
avrcp
stereotype
asp.net-2.0
jad
applinks
shunting-yard
unityvs
rails-migrations
pyalgotrade
android-relativelayout
webshim
fade
zend-db-table
stringstream
symbian3
volatility
bindinglist
win-prolog
nsundomanager
file-processing
xhtmlrenderer
lwp
excellibrary
nstoolbar
iphone-maps
pkcs#7
morfik
manuals
qlibrary
j++
cons
asp.net-1.1
urlscan
paperless

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