PROBLEM IN VIEW CODE IN MVC4

Gaurpriya Bishnoi

Total Post:7

Points:49
Posted by  Gaurpriya Bishnoi
LINQ  Mvc4 
 987  View(s)
Ratings:
Rate this:
hi i am face problem in view code

Controller
public ActionResult Testing()
        {
            //var res = (from empname in db.UserMasters
            //              select empname.EmployeeId).Distinct().ToList();
          //var res = db.UserMasters.Select(x=> new  UserMaster{EmployeeId=x.EmployeeId}).Distinct().ToList();
            var res = db.UserMasters.Select(x=>x.EmployeeId).Distinct();
            return View(res);
        }

View Code Here

@model IEnumerable<SampleApp.Models.UserMaster>
@{
    ViewBag.Title = "Testing";
}

@foreach (var item in Model)
{
    <li><a href="#">@item.EmployeeId</a></li>
}

screenshot


  1. Pawan Shukla

    Post:38

    Points:274
    Re: Problem in View Code in MVC4

    Hi Gauripriya


    Change code in razor view file..
    @model IEnumerable<SampleApp.Models.UserMaster>
    Replace with
    @model List<SampleApp.Models.UserMaster>

Answer

NEWSLETTER

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