RE: ObjectDataSource DateTime isuue with en-gb culture
- From: "Phillip Williams" <Phillip.Williams@xxxxxxxxxxxx>
- Date: Wed, 14 Dec 2005 07:31:05 -0800
Hi Anne,
How do you define the "CreateDate" within the
"B3.Mailer.BusinessEntities.Campaign" class?
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Anne Catterick" wrote:
> Hi,
>
> I have an british ASP.Net 2.0 application which is doing what (should) be
> very simple. But I am having issues.
>
> On my page I have a GridView as follows (some tags excluded for easy reading):
>
> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
> DataSourceID="ObjectDataSource1" DataKeyNames="Id"
> OnRowUpdated="GridView1_RowUpdated">
> <Columns>
> <asp:BoundField DataField="CreateDate" HeaderText="Create Date"
> SortExpression="CreateDate"
> DataFormatString="{0:d}" ApplyFormatInEditMode="True"
> ReadOnly="True" HtmlEncode="False">
> <HeaderStyle Wrap="False" />
> </asp:BoundField>
> <asp:CommandField ButtonType="Image"
> CancelImageUrl="~/images/manager/false.gif"
> EditImageUrl="~/images/manager/edit.gif"
> ShowEditButton="True" UpdateImageUrl="~/images/manager/true.gif" />
> </Columns>
> </asp:GridView>
>
> This is bound to an ObjectDataSource defined as follows:
>
> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
> SelectMethod="GetCampaigns"
> TypeName="B3.Mailer.BusinessEntities.Campaign"
> DataObjectTypeName="B3.Mailer.BusinessEntities.Campaign"
> InsertMethod="Insert" UpdateMethod="Update">
> <SelectParameters>
> <asp:SessionParameter Name="clientId" SessionField="ClientId"
> Type="Int32" />
> </SelectParameters>
> </asp:ObjectDataSource>
>
> The update method is defined as:
>
> public static void Update(Campaign campaign)
> {
> }
>
> However, when I edit a row in the GridView and press the update button I get
> the following error:
>
> [InvalidOperationException: Cannot convert value of parameter 'CreateDate'
> from 'System.String' to 'System.DateTime']
> System.Web.UI.WebControls.ObjectDataSourceView.ConvertType(Object value,
> Type type, String paramName) +485
> System.Web.UI.WebControls.ObjectDataSourceView.BuildObjectValue(Object
> value, Type destinationType, String paramName) +217
> System.Web.UI.WebControls.ObjectDataSourceView.BuildDataObject(Type
> dataObjectType, IDictionary inputParameters) +548
> System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
> keys, IDictionary values, IDictionary oldValues) +1520
> System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values,
> IDictionary oldValues, DataSourceViewOperationCallback callback) +179
> System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32
> rowIndex, Boolean causesValidation) +1137
> System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
> causesValidation, String validationGroup) +835
> System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs
> e) +162
> System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
> System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source,
> EventArgs e) +118
> System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
> System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +106
> System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String
> eventArgument) +200
>
> System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +32
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3840
>
> This appears to be caused by the date being in UK format (dd/mm/yyyy - which
> is correct for this application) as dates which could also be in US format
> (i.e. 12/12/2005) do not throw this error.
>
> Both my browser and development machine are set to en-gb but there is no
> Culture attribute set on the @Page tags on the page.
>
> Is this a bug in the ObjectDataSource not conforming to globalization or am
> I missing somthing?
>
> Any help you can give will be much appreciated. Thanks in advance for your
> help.
>
> Regards,
>
> Anne.
>
.
- Follow-Ups:
- RE: ObjectDataSource DateTime isuue with en-gb culture
- From: Anne Catterick
- RE: ObjectDataSource DateTime isuue with en-gb culture
- References:
- ObjectDataSource DateTime isuue with en-gb culture
- From: Anne Catterick
- ObjectDataSource DateTime isuue with en-gb culture
- Prev by Date: RequiredFieldValidator on RadioButtons?
- Next by Date: Re: Problems with IIS 5.1 & Oracle9i
- Previous by thread: ObjectDataSource DateTime isuue with en-gb culture
- Next by thread: RE: ObjectDataSource DateTime isuue with en-gb culture
- Index(es):