I AM USING MVC4 AND THEIR IS PROBLEM IN DROPDOWN LIST CAN YOU CHECK PLEASE

anand kumar

Total Post:2

Points:14
Posted by  anand kumar
Mvc4 
 461  View(s)
Ratings:
Rate this:
     public ActionResult Index(string searchstring, string search,string dept)
        {
   var DesigList = new List();
            var desigQuery = from d in db.students
                             orderby d.dept
                             select d.dept;

            DesigList.AddRange(desigQuery.Distinct());
            ViewBag.Desig = new SelectList(DesigList);


            if (!String.IsNullOrEmpty(dept))
            {
                contact = contact.Where(x => x.dept == dept);
            }
            return View(contact);
        }

and this is Index.view

 @using (Html.BeginForm())
    {
    <p>
        FirstName: @Html.TextBox("searchstring") &nbsp;   Lastname:  @Html.TextBox("search") &nbsp; DEPT: @Html.DropDownList("dept","All")
        <input type="submit" value="Search" />
    </p>
    }
   

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!