Cast from string "" to type 'Date' is not valid

Z

zafzal

Hello all,


I have a textbox in my asp.net (vb.net) aplicattion, I need to
assign it's value to a Variable of type DATE, but it's not a required
field, so sometimes I want to send a blank field.

I declared a variable as a date datatype and when it´s going to
receive
the content of the text field, it shows the following error "Cast from
string "" to
type 'Date' is not valid"

What should I do to handle this problem.
 
H

Hans Kesting

Hello all,
I have a textbox in my asp.net (vb.net) aplicattion, I need to
assign it's value to a Variable of type DATE, but it's not a required
field, so sometimes I want to send a blank field.

I declared a variable as a date datatype and when it´s going to
receive
the content of the text field, it shows the following error "Cast from
string "" to
type 'Date' is not valid"

What should I do to handle this problem.

Date (is that the same as DateTime?) can't handle an "empty" value.
What I usually do is use DateTime.MinValue to signal a "missing date".

Hans Kesting
 
J

jamesb

Check the the textbox.text value is not equal to "" before doing the
conversion. If it is equal to "" then don't convert...
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top