Hi all,
I am working on a project. Everything is working fine except the date formating. I have five listboxes and a dropdownlist box controls. The 5 listboxes I have populated from the underlying database view and dropdownlist box is populated by the date in the same view. When I select any values from the listboxes the information is displayed in the Repeater Control. I also want to select the date including the 5 listboxes to display the result in the Repeater but when I select the date which is 2006 from the Dropdownlist it give me this error message:
" String was not recognized as a valid DateTime"
I am adding listboxes and dropdownlist into the arraylist which works fine but the dropdownlist with the date won't work. I cannot figue out why is that. Here is the code I am using for Dropdownlist for the date I mean for the year 2006:
if ((DropDownList1 .SelectedValue != null) && (DropDownList1. SelectedValue != ""))
{
DateTime d = Convert.ToDateT ime(DropDownLis t1.Text); // this line gives error
string t = d.ToString("dd-mm-yyyy");
Alist.Add(
"OrderDate = CONVERT(DATETIM E, '" + t + "', 102)");
}
So it gives me this error : " String was not recognized as a valid DateTime". The whole code works fine for the NorthWind the free database I tried as an example but not for this project
Looking forward to your reply
Koonda
I am working on a project. Everything is working fine except the date formating. I have five listboxes and a dropdownlist box controls. The 5 listboxes I have populated from the underlying database view and dropdownlist box is populated by the date in the same view. When I select any values from the listboxes the information is displayed in the Repeater Control. I also want to select the date including the 5 listboxes to display the result in the Repeater but when I select the date which is 2006 from the Dropdownlist it give me this error message:
" String was not recognized as a valid DateTime"
I am adding listboxes and dropdownlist into the arraylist which works fine but the dropdownlist with the date won't work. I cannot figue out why is that. Here is the code I am using for Dropdownlist for the date I mean for the year 2006:
if ((DropDownList1 .SelectedValue != null) && (DropDownList1. SelectedValue != ""))
{
DateTime d = Convert.ToDateT ime(DropDownLis t1.Text); // this line gives error
string t = d.ToString("dd-mm-yyyy");
Alist.Add(
"OrderDate = CONVERT(DATETIM E, '" + t + "', 102)");
}
So it gives me this error : " String was not recognized as a valid DateTime". The whole code works fine for the NorthWind the free database I tried as an example but not for this project
Looking forward to your reply
Koonda
Comment