How to see DateTimePicker is NULL

  • Thread starter Thread starter Rinaldo
  • Start date Start date
R

Rinaldo

Hi,

I have the following code:

DateTimePicker datum = (DateTimePicker)sender;

string HuidigeDatum = datum.Text.ToString().Trim();
if (HuidigeDatum == "")
{
MessageBox.Show("Datumveld is leeg.");

}

How to see if the field is empty. The code above doesn't work.

Rinaldo
 
Rinaldo said:
Hi,

I have the following code:

DateTimePicker datum = (DateTimePicker)sender;

string HuidigeDatum = datum.Text.ToString().Trim();
if (HuidigeDatum == "")
{
MessageBox.Show("Datumveld is leeg.");
}

How to see if the field is empty. The code above doesn't work.

Rinaldo

Since DateTime is not nullable, your string should never be "". Are you
getting an error, and if so, what is the error?
 
Hi Mike,

It is from a datetimepicker textbox. If I do not enter a value but leave it
on the date thats given the database gives an error that the field can not
be empty or null. Somewhere must a value be null or empty, but where?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top