I am having the Controller as follows...
public ActionResult Create()
{
ViewBag.Dept = (DbStudent.StudentDetails.Select(s => s.StudDept)).Distinct();
return View();
}
//
// POST: /Student/Create
[HttpPost]
public ActionResult Create(StudentDetail studentdetail)
{
try
{
// TODO: Add insert logic here I used Stored procedure for it
var query = DbStudent.StudInsert(studentdetail.StudName,
studentdetail.StudDept,
studentdetail.Mark1, studentdetail.Mark2);
return RedirectToAction("Index");
}
In View I included the following
<div class="editor-field">
@Html.DropDownListFor(model => model.StudDept, new SelectList(ViewBag.Dept as System.Collections.IEnumerable),
"Select Any Department")
</div>
The DropDown get populated , But While Selecting the Dropdown I get only null values .. Please help me . I don't know what i am doing wrong
Thanks In Advance
Regards, Surya