Home > DeveloperSection > Forums > i am using mvc4 and their is problem in dropdown list can you check please
anand kumar
anand kumar

Total Post:2

Points:14
Posted on    August-08-2016 1:30 AM

 ASP.NET MVC Mvc4 
Ratings:


 0 Reply(s)
 173  View(s)
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>
    }
   


Don't want to miss updates? Please click the below button!

Follow MindStick