String was not recognized as a valid DateTime.
-
Line 260: newCandidate.FirstNameAR = txtFirstNameAR.Text.Trim();
Line 261: newCandidate.LastNameAR = txtLastNameAR.Text.Trim();
Line 262: newCandidate.DOB = Convert.ToDateTime(txtDOB.Text);
Line 263: newCandidate.Address = txtAddress.Text;
Line 264: newCandidate.CountryID = Convert.ToInt16(ddlCountry.SelectedValue); -
Line 260: newCandidate.FirstNameAR = txtFirstNameAR.Text.Trim();
Line 261: newCandidate.LastNameAR = txtLastNameAR.Text.Trim();
Line 262: newCandidate.DOB = Convert.ToDateTime(txtDOB.Text);
Line 263: newCandidate.Address = txtAddress.Text;
Line 264: newCandidate.CountryID = Convert.ToInt16(ddlCountry.SelectedValue); -
Why have you posted this with a link to your QA post? Please post questions in one forum only.
sorry for that, plz help me.
-
Line 260: newCandidate.FirstNameAR = txtFirstNameAR.Text.Trim();
Line 261: newCandidate.LastNameAR = txtLastNameAR.Text.Trim();
Line 262: newCandidate.DOB = Convert.ToDateTime(txtDOB.Text);
Line 263: newCandidate.Address = txtAddress.Text;
Line 264: newCandidate.CountryID = Convert.ToInt16(ddlCountry.SelectedValue);I would not use
Convert.ToDateTime
with a text/string input. Instead try usingTryParse
with datetime. DateTime.TryParse Method (String, DateTime) (System)[^] -
Line 260: newCandidate.FirstNameAR = txtFirstNameAR.Text.Trim();
Line 261: newCandidate.LastNameAR = txtLastNameAR.Text.Trim();
Line 262: newCandidate.DOB = Convert.ToDateTime(txtDOB.Text);
Line 263: newCandidate.Address = txtAddress.Text;
Line 264: newCandidate.CountryID = Convert.ToInt16(ddlCountry.SelectedValue);Actually (to build on Slacker's answer), the return value of the
TryParse
method is either true or false, and if true, the specifiedout
parameter contains the parsedDateTime
value. If the return value is false, the specified string was not in a recognizableDateTime
string format. Additionally, if you know for sure what the format of the string will be, you can useParseExact
. For details about using either of these methods, google is, once again, your friend.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Actually (to build on Slacker's answer), the return value of the
TryParse
method is either true or false, and if true, the specifiedout
parameter contains the parsedDateTime
value. If the return value is false, the specified string was not in a recognizableDateTime
string format. Additionally, if you know for sure what the format of the string will be, you can useParseExact
. For details about using either of these methods, google is, once again, your friend.".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Thanks, I corrected my post. Funny, I use this all the time, yet I posted its implementation incorrectly. :doh: :-\
-
I would not use
Convert.ToDateTime
with a text/string input. Instead try usingTryParse
with datetime. DateTime.TryParse Method (String, DateTime) (System)[^]You can't set a
DateTime
to null. :)".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
You can't set a
DateTime
to null. :)".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
I would not use
Convert.ToDateTime
with a text/string input. Instead try usingTryParse
with datetime. DateTime.TryParse Method (String, DateTime) (System)[^] -
Of course you can't. But I don't know how they are working with the actual data and displaying it. I am starting to regret posting an answer to his question. :sigh:
-
That's not what I would call a reasonable practice. I prefer my DateTimes to be valid in some way (and use
new DateTime(0)
to accomplish that).".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Of course you can't. But I don't know how they are working with the actual data and displaying it. I am starting to regret posting an answer to his question. :sigh:
Slacker007 wrote:
I am starting to regret posting an answer to his question. :sigh:
Waaa-waaaa-waaaaaaaaaaa. :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
That's not what I would call a reasonable practice. I prefer my DateTimes to be valid in some way (and use
new DateTime(0)
to accomplish that).".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013John Simmons / outlaw programmer wrote:
That's not what I would call a reasonable practice.
It is a possible and valid scenario, whether you John, agree with it or not. Just saying... For instance, shipping dates - they are usually null until something actually ships.
-
Slacker007 wrote:
I am starting to regret posting an answer to his question. :sigh:
Waaa-waaaa-waaaaaaaaaaa. :)
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013You know John, you don't "always" have to be an asshole.
-
You know John, you don't "always" have to be an asshole.
Yes. Yes, I do. If I wasn't always an assh*le, I would disappoint my legions of fans. Besides, me being an assh*le is really the only constant in life any more that absolutely EVERYBODY can count on. Beyond that, I was just poking you in the ribs. If you're honestly butt-hurt, I can call a waaa-mbulance for you. :) BTW, I'm the one that voted your original answer a 5.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
John Simmons / outlaw programmer wrote:
That's not what I would call a reasonable practice.
It is a possible and valid scenario, whether you John, agree with it or not. Just saying... For instance, shipping dates - they are usually null until something actually ships.
We can argue the validity of nulls all day. I don't like 'em, and I strive to resolve them in some way.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
John Simmons / outlaw programmer wrote:
That's not what I would call a reasonable practice.
It is a possible and valid scenario, whether you John, agree with it or not. Just saying... For instance, shipping dates - they are usually null until something actually ships.
-
sorry for that, plz help me.
This is not the correct place to write this content.
hi
-
I would not use
Convert.ToDateTime
with a text/string input. Instead try usingTryParse
with datetime. DateTime.TryParse Method (String, DateTime) (System)[^]HOW TO RECTIFY ERROR
-
HOW TO RECTIFY ERROR
Why are you yelling at me?