mid*_*pat 4 c# timespan asp.net-mvc-3
我有一个MVC3应用程序,其中我想设置一个时间跨度,例如2天和5小时.当我输入02:05:00:00时,它给了我以下例外:
System.OverflowException: SqlDbType.Time overflow. Value '2.05:00:00' is out of range. Must be between 00:00:00.0000000 and 23:59:59.9999999.
Run Code Online (Sandbox Code Playgroud)
当我输入05:00:00时,它正确地将5小时保存到数据库中.根据MSDN timespan有一天属性.我如何正确设置日期?
模型:
public class ProductionTimeVM
{
[Required]
public TimeSpan DefaultTime { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我看来,我只是使用:
@Html.TextBoxFor(x => x.DefaultTime)
Run Code Online (Sandbox Code Playgroud)
对于我的控制器:
public ActionResult SaveProductionTime(ProductionTimeVM vm)
{
ProductionTime productionTime = new ProductionTime();
productionTime.Default = vm.DefaultTime;
//some more code
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
1328 次 |
| 最近记录: |