Search code examples
asp.net-mvcasp.net-mvc-5

Call SelectListItem in class library


I have a class library in solution. There are models and repositories and I want to create static list in class library to use in project. one of the static lists must return a list of data in "SelectListItem" type

   public class StaticLists
    {
        public List<SelectListItem> IsletmeTipleri()
        {
           return null
        }
    }

But I'm getting error;

The type or namespace name 'SelectListItem' could not be found.

I should call 'using System.Web.Mvc' to use SelectListItem but I can't call in class library.

Can I call SelectListItem in class library? How do I do if I can call ?


Solution

  • Add Reference of System.Web.Mvc.dll to you Class Libary project.

    Reference of System.Web.Mvc