【发布时间】:2022-07-29 12:03:01
【问题描述】:
我正在处理一个项目,但我遇到了数据库或控制器问题。
这是我的控制器部分:
[HttpPost]
public ActionResult ConfirmHotelReservation(int? hotelid, int? customerid)
{
TBLHOTELREZERVASYON reservation = new TBLHOTELREZERVASYON();
reservation.hotel = hotelid;
reservation.musteri = customerid;
db.TBLHOTELREZERVASYON.Add(reservation);
db.SaveChanges();
return RedirectToAction("Index");
}
这是cshtml部分:
@using (Html.BeginForm("ConfirmHotelReservation", "Hotel", new { hotelid = TempData["hotel_id"], customerid = Session["customer_id"] }, FormMethod.Post))
{
<label style="color:black"> Başlangıç Tarihi</label>
@Html.TextBoxFor(x => x.baslangic, new { @class = "form-control", @required = "required" })
<br />
<label style="color:black"> Bitiş Tarihi</label>
@Html.TextBoxFor(x => x.bitis, new { @class = "form-control", @required = "required" })
<br />
<label style="color:black">Kişi Sayısı</label>
@Html.DropDownListFor(x => x.kisi_sayisi, (List<SelectListItem>)ViewBag.person, new { @class = "form-control" })
<br />
<button class="btn btn-info">Onayla</button>
}
hotelid 和 customerid 已添加,但 baslangic、bitis 和 kisi_sayisi 未添加
enter code here
我该如何解决这个问题?
【问题讨论】:
-
您没有在您发布的第一个代码 sn-p 中设置这些值,您希望它们如何设置?
-
你说得对,我刚开始就错过了这个。已经解决了,非常感谢
标签: c# asp.net asp.net-mvc