String was not recognized as a valid datetime.

Aug 15 2016 3:24 AM
hi guys,

I have an asp.net application in c#.

i have created one page to insert new candidate.In which i want to store candidate DOB.

When i'm giving DOB: 04/04/1980.

I'm getting this error.

Hide Copy Code
String was not recognized as a valid DateTime. 

What I have tried:

Hide Copy Code
newCandidate.FirstNameAR = txtFirstNameAR.Text.Trim(); newCandidate.LastNameAR = txtLastNameAR.Text.Trim(); newCandidate.DOB = Convert.ToDateTime(txtDOB.Text);//Error newCandidate.Address = txtAddress.Text; newCandidate.CountryID = Convert.ToInt16(ddlCountry.SelectedValue); 

i have added one label for testing.. as,
Hide Copy Code
label1.Text = DateTime.Now.ToShortString(); 

and i got, hijri date. But not G-Date. But my system in clock is display G-Date.

i have checked my clock setting and region as well.

How to solve this. Please guys help me.


Thanks
 
 

Answers (2)