Search code examples
c#.netienumerableilist

Can't I use IEnumerable() on .ascx?


This is my code :

protected IEnumerable<MyObject> CategoriesHotelsFiltrati;
CategoriesHotelsFiltrati.Union(CategoriesHotels.Where(o => o.Comune != null && CategoriesLocalitaSelezionate.Contains(o.Comune.UniqueID)));

now, on .asxc, if I try to do :

<% 
    if (m_oHotelsFiltrati == null || m_oHotelsFiltrati.Count()==0)
    {
        Response.Write("hello");
    }
%>  

seems that it doesnt find .Count() method. It says somethings about "using" or "assembly". Strange, with IList<> this works perfectly...why?


Solution

  • You need to add the following line to your *.ascx file:

    <%@ Import namespace="System.Linq" %>
    

    See this link for more details.