ObjectDataSource DateTime Parameter could not convert

S

Steve Lloyd

Hi,
I am using an objectdatasource to control a formview and have an update
command set.

The problem is that when i call the update command I get an Error
"Cannot convert value of parameter 'DateDue' from 'System.String' to
'System.DateTime'"

Two of the update fields are dates and I am entering them in dd/mm/yyyy
format, they work fine in mm/dd/yyyy but this is not what I need.

I have tried forcing the parameters to use the DateTime like explained in
http://www.webswapp.com/codesamples/aspnet20/updateparameters/error.aspx but
I still get the error. Can anyone help?

these are the text boxes in my update template
<asp:TextBox ID=TextBoxCreatedEdit Width=100px CssClass=textboxsmall
runat=server Text='<%# Bind("DateEntered", "{0:dd/MM/yyyy}")
%>'></asp:TextBox>
<asp:TextBox ID=TextBoxDueEdit Width=100px CssClass=textboxsmall
runat=server Text='<%# Bind("DateDue", "{0:dd/MM/yyyy}") %>'></asp:TextBox>

Here is the object DataSource

<asp:ObjectDataSource ConvertNullToDBNull=True
ID="ObjectDataSourceTaskdetails" runat="server"
DataObjectTypeName="LaxeyPartners.Tradelog.Components.Tasks.TaskDetails"
DeleteMethod="RemoveAt" InsertMethod="Add" SelectMethod="GetItems"
TypeName="LaxeyPartners.Tradelog.Components.Tasks.TaskCollection"
UpdateMethod="Update">
<DeleteParameters>
<asp:parameter Name="index" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name=DateDue Type=DateTime ConvertEmptyStringToNull=true />
<asp:parameter Name=DateEntered Type=DateTime ConvertEmptyStringToNull=true
/>
</UpdateParameters>
</asp:ObjectDataSource>

Thanks for any help you can give
 
S

Steve Lloyd

typical, I search for an answer all day, post a problem and then fix it 10
mins later!

I forced a date conversion on the NewValues in the Updating event of the
FormView.

Sorry to clog up the news group...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top