【问题标题】:Cannot convert the value of parameter 'Date' to the type 'System.DateTime'.'无法将参数“Date”的值转换为“System.DateTime”类型。
【发布时间】:2015-05-13 10:20:17
【问题描述】:

我使用EntityDataSource,格式化日期后出现错误转换

像这样:DataFormatString="{0:dd/MM/yyyy}"

[EntityDataSourceValidationException: Error while setting property 'fromDate': 'Cannot convert the value of parameter 'fromDate' to the type 'System.DateTime'.'.]
   Microsoft.AspNet.EntityDataSource.EntityDataSourceView.ConvertProperties(IDictionary values, PropertyDescriptorCollection propertyDescriptors, ParameterCollection referenceParameters, Dictionary`2 convertedValues) +737
   Microsoft.AspNet.EntityDataSource.EntityDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +383
   System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +84
   Telerik.Web.UI.GridTableView.PerformDelete(GridEditableItem editedItem, Boolean suppressRebind) +228
   Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +2417
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +91
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37

我的 aspx:

 <telerik:GridDateTimeColumn HeaderText="تاريخ البداية" UniqueName="fromDate" SortExpression="fromDate" DataField="fromDate" DataFormatString="{0:dd/MM/yyyy}"></telerik:GridDateTimeColumn>

注意:fromDate 在 sqlserver db 中属于 Date 类型

【问题讨论】:

  • DataField="fromDate" 不应该是DataField=fromDate
  • @SonerGönül:你能解释一下你的意思吗? DataField 是网格列的属性

标签: c# asp.net entity-framework entity-framework-6 radgrid


【解决方案1】:

试试看:

<telerik:GridBoundColumn DataField="fromDate" DataType="System.DateTime" HeaderText="تاريخ البداية"     
  UniqueName="fromDate" DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="false"/> 

【讨论】:

  • 插入没问题,但是当我尝试删除行时,我得到了同样的错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-22
  • 2021-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-30
相关资源
最近更新 更多