私はコントローラーを持っています:
[HttpPost]
public ActionResult Create(Auction auction)
{
var db = new EbuyDataContext();
db.Auctions.Add(auction);
db.SaveChanges();
return View(auction);
}
モデル:
public class Auction
{
public long Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public decimal StartPrice { get; set; }
public decimal CurrentPrice { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }}
}
そしてビュー:
@model Ebuy.Website.Models.Auction
@using (Html.BeginForm())
{
<p>
//All the information fields...
@Html.LabelFor(model => model.EndTime)
@Html.EditorFor(model => model.EndTime)
</p>
}
実行しようとすると、次のエラーが表示されます。
datetime2 データ型を datetime データ型に変換すると、範囲外の値になりました。
model-controller-view は、1 対 1 でコピーされた本からのものです。
EndTime
このエラーが発生しないように、フィールドに入力する必要がある形式は何ですか?