edaj6
asked on
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" />
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; }...
ASKER
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
The datatype of BO.Date is DateTime.
..Jakob
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.Tex t.ToString ());
Since I use a gridview for uodateing I had to add to gv_RowUpdating:
TextBox txtDate = (TextBox)row.FindControl("
e.NewValues["Date"] = DateTime.Parse(txtDate.Tex
Great.
But wouldn't this be fine as well:
e.NewValues["Date"] = DateTime.Parse(txtDate.Tex t);
/gustav
But wouldn't this be fine as well:
e.NewValues["Date"] = DateTime.Parse(txtDate.Tex
/gustav
string dateText = "19-09-2011";
DateTime date = DateTime.Parse(dateText);
Then pass variable date.
/gustav