trying to put a strongly typed partial view on a homepage in asp.net but it wont seem to work it, here is my code
new to asp.net and partial views.
Controller :
public ActionResult VenuePartial()
{
ViewData["Message"] = _entities.VenuePartialList();
return View();
}
Repository :
public IEnumerable<Venue> VenuePartialList()
{
var list = from s in _entities.Venue
orderby s.name ascending
select s;
return list.ToList();
}
IRepository :
IEnumerable<Venue> VenuePartialList();
Index Page :
<%Html.RenderPartial("~/Views/Venue/VenuePartial.ascx");%>
Any help would be grateful asap please regards T
Maybe you need to pass a model to this partial:
And by the way WTF are you using
ViewData["Message"]to pass a model instead of using a model and a strongly typed view:and then:
This obviously assumes that your partial is strongly typed to
IEnumerable<Venue>. If it is typed to a singleVenueyou might also consider using Editor/Display Templates. So in your main view:and in the corresponding display template (
~/Views/Shared/DisplayTemplates/Venue.ascx):and now the display template will be rendered for each item of the model collection.