I'm using Ajax date picker control ....I'm showing selected date like dd/mm/yyyy .This is working very fine but some times suddenly it showing error like
"String was not recognized as a valid DateTime" .Now also I'm able to use the date picker without any error in local after publishing in Server some times it showing the above error ...why???cn any one help me plz???

Zeeshan AzimRank #1,613 · 967 reputationPosted Nov 11, 2014, 9:11 PM EST
string Date2 = DateTime.Parse(datepicker.Text);
and keep your code in try catch blocks. Thanks
priya AvanigaddaRank #7,836 · 233 reputationPosted Nov 11, 2014, 9:21 PM EST
Joginder BangerRank #360 · 7K reputationPosted Nov 11, 2014, 9:24 PM EST
in your code, you can do the following:
string theDate = dateTimePicker1.Value.ToShortDateString();or, if you'd like to specify the format of the date:
string theDate = dateTimePicker1.Value.ToString("yyyy-MM-dd");priya AvanigaddaRank #7,836 · 233 reputationPosted Nov 11, 2014, 10:52 PM EST
Mariyappan sivathanu5 reputationPosted Nov 11, 2014, 11:37 PM EST
Convert.ToDateTime(DateTime.Parse(txtBeginDT.Text.Trim())
instead of
DateTime.Parse(txt.text.Trim())
priya AvanigaddaRank #7,836 · 233 reputationPosted Nov 12, 2014, 12:06 AM EST
.DAL:I'm using fr date format
var listSplit = DOB.Split('/'); string finalList = listSplit[1] + "/" + listSplit[0] + "/" + listSplit[2]; string datetime = DateTime.Now.ToString(finalList);
DateTime dateof = DateTime.Parse(finalList);
cmd.Parameters.Add("@DateofBirth", dateof);
In .cs I'm accesing this ....
I tried ur code also but im getting same error ..so cn any one tell me how to slve please??
Abhay ShankerRank #375 · 6.7K reputationPosted Nov 12, 2014, 12:19 AM EST
DateTime.ParseExact(finalList, "dd/MM/yyyy", CultureInfo.InvariantCulture)
or
DateTime.ParseExact(finalList, "MM/dd/yyyy", CultureInfo.InvariantCulture)
priya AvanigaddaRank #7,836 · 233 reputationPosted Nov 12, 2014, 12:28 AM EST