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

Client HTTP Handling & ETag
Missing network sent/received
Read XML response webservice
using .Equals() failing in Predicatebuilder
Can I delete xxxxxxxAreaRegistration.cs?
jqgrid toolbar search or external search feature
Splitting individual element in a List<string>?
C# Loop, SQL and retrieving infos
When checking for a type, is it better to use “is” with “as” or just “as” and a null check? [duplicate]
Pass `List<List<Bitmap>>` as ref
Generate stored procedures for SQL Server
give a font to gridview that doesn't exist in all systems
Group and join give missing field
get number of sheet in xls excel file
SQL Server 2008 R2: How do I “pause” a clustered index while the server is being written to?
Why does this color comparison fail?

Categories

HOME
airflow
excel-formula
repository
youtube-api
optimization
virtual-machine
postsharp
app-store
query-string
sms
hibernate-mapping
pdf-generation
sahi
soap-client
ios-universal-links
google-my-business-api
mongoimport
guidewire
ofbiz
django-rest-auth
udeploy
restructuredtext
angular2-pipe
fastboot
ecmascript-2017
android-wear-2.0
suitescript
nsopenpanel
smart-device
proof-general
setup-project
csproj
pypy
ds-5
webclient
pyenv
matrix-multiplication
var
jquery-inputmask
idea-plugin
server-side-swift
tapply
flume-ng
servicebus
codepen
hierarchical-clustering
aws-rds
kendo-scheduler
chain
portaudio
optional-parameters
alfred
require-handlebars
nimbus
django-taggit
jde
nd4j
code-translation
app-data
bioconductor
webservices-client
identifying
tess4j
tooltwist
xml-simple
system.diagnostics
avd
asp.net-2.0
cl.exe
quickfixn
launcher
fxmlloader
breeze-sharp
sat4j
azure-worker-roles
serializer
connections
mdp
objectdatasource
record-locking
windows-scheduler
codeigniter-form-helper
blotter
netzke
google-email-audit-api
jqzoom
log-shipping
vectorwise
jexcelapi
n2
excellibrary
fxcopcmd
database-agnostic

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