Hi there,
When you say "empty" I presume you mean blank, no date at all, or in proper terms -
null
? If you want to submit a
null
date value to your databse, make sure your data column allows nulls then set the value to null. Do no try to pass in empty strings - this wont work - unless you are using a varchar or nchar field for stroing adtes which is bad practice anyway...
Without your code this is very hard but your code should look something like this:
DateTime? DateToSubmit = null;
if(!string.IsNullOrEmpty(txtDate.text))
{
DateTime.TryParse(txtDate.Text, out DateToSubmit);
}
MyDataObject.MyDate = DateToSubmit;
MyDataObject.MyDate = DateToSubmit.HasValue ? DateToSubmit.Value.ToString() : "";
Hope this helps,
Ed