views:

17

answers:

1
public class catnewModel
{
    public IQueryable<category> dl { get; set;   }
    public IQueryable<product> dr { get; set;   }
}

and my controller

public ActionResult Index()
{

    var pr = db.products;
    var pl = db.categories;

    catnewModel model = new catnewModel();
    model.dr = pr;
    model.dl = pl;

    return View(model);
}

in my view i try to iterate over

 <% foreach (var item in Model.dr)  %>

but i get error on

error CS1061: 'System.Collections.Generic.IEnumerable' does not contain a definition for 'dr' and no extension method

+2  A: 

Most likely because Your view uses wrong class.

Currently it's something like:

<%@ Page Language="C#" 
  MasterPageFile="~/Views/Shared/Site.Master" 
  Inherits="ViewPage<IQueryable<category>>" %>

But it should be:

<%@ Page Language="C#" 
  MasterPageFile="~/Views/Shared/Site.Master" 
  Inherits="ViewPage<catnewModel>" %>

Add Your view declaration to Your answer to clarify that out.

Arnis L.
ok, now it's work,
eyalb
+1 @eyalb please accept the answer
eglasius