` public ActionResult Edit(int id = 0)
{
property property = db.Properties.Find(id);
try
{
ViewBag.City = new SelectList(db.Cities, "CityId", "City", property.CityId);
ViewBag.Locality_Id = new SelectList(db.Areas, "Locality_Id", "Locality", property.Locality_Id);
ViewBag.citylist = _data.getCity();
ViewBag.typeproperty = _data.TypeProperty();
ViewBag.Rooms = _data.RoomDetails();
ViewBag.bath = _data.Bathroom();
ViewBag.twowheel = _data.twowheeler();
ViewBag.fourwheel = _data.fourwheeler();
ViewBag.dir = _data.Direction();
ViewBag.floor = _data.Flooring();
ViewBag.water = _data.WaterSupplies();
ViewBag.furnish = _data.Furnishes();
ViewBag.Amenities = new SelectList(db.Amenities, "AmenitiesId", "Amenitie");
}
catch (Exception ex)
{
Console.Write(ex.InnerException.StackTrace.ToString());
}
if (property == null)
{
return HttpNotFound();
}
return View(property);
}`
<div class="form-box-left">
<h5>* Select The City :</h5>
@Html.DropDownList("CityId", null, "Select City", new { @class = "text-box", Id = "City" })
@Html.ValidationMessageFor(model => model.CityId)
<h5>* Locality :</h5>
相同的代碼,但不在編輯頁面上。我改變了我的代碼,但仍未提交數據。雖然時間過得還可以。具有關鍵的ViewData的項目「CityId」的類型「System.Int32」的,但必須是類型「的IEnumerable <SelectListItem>」我使用的創建頁面及其工作有
我們可以看到編輯和創建操作方法的控制器代碼嗎? – JTMon 2014-09-02 12:35:59