DateTime ddmmyyyy error when update recordset with BO

I have a gridview where ObjectDataSource is a list of BO.

One field in DB and BO is DateTime formatted ddmmyyyy.
The gridview shows all records fine, but when I try to update I get an error when the day is is after the 12th (eg 19-09-2011):
Cannot convert value of parameter 'Date' from 'System.String' to 'System.DateTime'

I guess the system expects a date time in us format, but I want to use ddmmyyyy format.
My web.config has
<globalization uiCulture="da" culture="da-DK" />


 
public class EBO
    {   public int EID { get; set; }
        public DateTime Date { get; set; }...

Open in new window

edaj6Asked:
Who is Participating?
 
Gustav BrockConnect With a Mentor CIOCommented:
Without knowing your code I guess it should be something like this:

BO.Date = DateTime.Parse(YourDateTextVariable);

or similar.

/gustav
0
 
Gustav BrockCIOCommented:
Try with:

string dateText = "19-09-2011";
DateTime date = DateTime.Parse(dateText);

Then pass variable date.

/gustav
0
 
edaj6Author Commented:
The DataField "Date" is a bound field, in my gridview I want to update. Where  should you code be, in my BO?
The datatype of BO.Date is DateTime.

..Jakob
0
 
edaj6Author Commented:
Thanks it works,

Since I use a gridview for uodateing I had to add to gv_RowUpdating:

TextBox txtDate = (TextBox)row.FindControl("txtDate");
e.NewValues["Date"] = DateTime.Parse(txtDate.Text.ToString());

0
 
Gustav BrockCIOCommented:
Great.
But wouldn't this be fine as well:

e.NewValues["Date"] = DateTime.Parse(txtDate.Text);

/gustav
0
All Courses

From novice to tech pro — start learning today.