forum

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

i am using mvc4 and their is problem in dropdown list can you check please

anand kumar 1315 08-Aug-2016
     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>
    }
   

Updated on 08-Aug-2016

Can you answer this question?


Answer

0 Answers

Liked By