public ActionResult UpdateBDDNBR(int? id)
{
BillingDropDownNBReason billingDropDownNbReason = db.BillingDropDownNBReasons.Find(id);
ViewBag.ListKey = new SelectList
(db.BillingDropDownNBReasons.Where(x => x.Active == true),
"ListKey", "ListValue");
BillingDropDownNBReasonDataTablesViewModel billingDropDownNbReasonBDDNBRvm =
new BillingDropDownNBReasonDataTablesViewModel();
return View(billingDropDownNbReasonBDDNBRvm);
}
public ActionResult SecondUpdateBDDNBR(int? ListKeyid)
{
if (ListKeyid == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
BillingDropDownNBReason billingDropDownNbReason = db.BillingDropDownNBReasons.Find(ListKeyid);
BillingDropDownNBReasonDataTablesViewModel billingDropDownNbReasonBDDNBRvm =
new BillingDropDownNBReasonDataTablesViewModel();
billingDropDownNbReasonBDDNBRvm.ListKey = billingDropDownNbReason.Listkey;
billingDropDownNbReasonBDDNBRvm.ListValue = billingDropDownNbReason.ListValue;
billingDropDownNbReasonBDDNBRvm.Description = billingDropDownNbReason.Description;
billingDropDownNbReasonBDDNBRvm.Active = (bool) billingDropDownNbReason.Active;
billingDropDownNbReasonBDDNBRvm.StartDate = billingDropDownNbReason.StartDate;
billingDropDownNbReasonBDDNBRvm.EndDate = billingDropDownNbReason.EndDate;
if (billingDropDownNbReasonBDDNBRvm == null)
{
return HttpNotFound();
}
return View(billingDropDownNbReasonBDDNBRvm);
}
I am receiving the following error:
System.Int32' but must be of type 'IEnumerable'
newcomber to MVC.
I have a table looks Like:
ListKey, int, NonNull
ListValue, int, NonNull
Desc, String, Null
Active, Bool, Null
StartDate, DateTime
EndDate, DateTime
On button click i hit action UpdateBDDNBR() but I have no ListKey Id yet. So I send View bag back to view. Loads fine I use .js to hit the next action SecondUpdateBDDNBR() error occurs at this point. I am trying to return the values associated with the ListKet ID to a set of bound @html Helpers for update and eventually also a create area. Why do I get the error and how to write code with proper IEnumerable.
$(document).ready(function () {
$("#ListKey").change(function () {
alert($(this).val());
document.location.href = '/IOTDBBillingAdmin/SecondUpdateBDDNBR?ListKeyid=' + $(this).val();
});
});
@Html.DropDownList("ListKey", Model.ListItems, ("--Select Reason--"), new { @class = "form-control", @id = "ListKey"})
Model
[Key]
public int? ListKey { get; set; }
[Required(ErrorMessage = "List Value is Required")]
[StringLength(250, ErrorMessage = "250 Charactors Max")]
public string ListValue { get; set; }
public IEnumerable<SelectListItem> ListItems { get; set; }
public int? ListKeyid { get; set; }
[Required(ErrorMessage = "Description is Required")]
[StringLength(500, ErrorMessage = "500 Charactors Max")]
public string Description { get; set; }
[Bindable(true)]
[SettingsBindableAttribute(true)]
public bool Active { get; set; }
[DataType(DataType.DateTime)]
public Nullable<System.DateTime> StartDate { get; set; }
[DataType(DataType.DateTime)]
public Nullable<System.DateTime> EndDate { get; set; }
public int RadioGroup { get; set; }
Aucun commentaire:
Enregistrer un commentaire