Controller
public ActionResult Index(int? id) { VarsityContext VarsityDB = new VarsityContext(); Varsity.Models.Configuration configuration = new Varsity.Models.Configuration();try { if (id != null) { configuration = VarsityDB.Configurations.Single(a => a.Conf_ID == id); ViewBag.Action = "Edit"; } else { ViewBag.Action = "Create"; } IEnumerable<SelectListItem> basetypes = new SelectList(cwConfiguration.getConfigurationTypes(), "Id", "Name", configuration.Conf_TypeName); ViewBag.Conf_Type = basetypes; ViewBag.Conf_TypeName = basetypes; }catch (Exception ex) { } return View(configuration);}
public ActionResult Index(int? id) { VarsityContext VarsityDB = new VarsityContext(); Varsity.Models.Configuration configuration = new Varsity.Models.Configuration();
public ActionResult Index(int? id)
{
VarsityContext VarsityDB = new VarsityContext();
Varsity.Models.Configuration configuration = new Varsity.Models.Configuration();
try
if (id != null)
configuration = VarsityDB.Configurations.Single(a => a.Conf_ID == id);
ViewBag.Action = "Edit";
}
else
ViewBag.Action = "Create";
IEnumerable<SelectListItem> basetypes = new SelectList(cwConfiguration.getConfigurationTypes(), "Id", "Name", configuration.Conf_TypeName);
ViewBag.Conf_Type = basetypes;
ViewBag.Conf_TypeName = basetypes;
catch (Exception ex) { } return View(configuration);}
catch (Exception ex)
return View(configuration);
View
@if (ViewBag.Action == "Edit")
@Html.DropDownList("Conf_Type", ViewBag.Conf_Type as SelectList, new { selected = @Model.Conf_TypeName, @class = "form-control" })
@Html.DropDownList("Conf_Type", ViewBag.Conf_Type as SelectList, "Select Type", new { required = "required", validationmessage = "Please select Type", selected = @Model.Conf_Type, @class = "form-control" })
@Html.HiddenFor(m => m.Conf_TypeName, ViewBag.Conf_TypeName as SelectListItem)
Attachment: images.rar