<div class="editor-label"> @Html.LabelFor(model => model.TaxID) </div> <div class="editor-field"> @Html.DropDownList("Tax", "select Tax class") @Html.ValidationMessageFor(model => model.TaxID) </div>
ViewBag.Tax = new SelectList(db.SHP_Taxes, "TaxID", "TaxName");
[HttpPost] public ActionResult NewProduct(Product newProduct) { if (ModelState.IsValid) { try { SHP_Product pro = new SHP_Product(); var max = db.SHP_Products.Select(x => x.ProductID).Max(); int inter = Convert.ToInt32(max); pro.TaxID = newProduct.TaxID; } catch (MembershipCreateUserException e) { } } ModelState.AddModelError("", "error occured"); // If we got this far, something failed, redisplay form return View(newProduct); }
@Html.DropDownListFor(model => model.TaxID, (SelectList)ViewBag.Tax)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)