First of I am a complete beginner at MVC. How would I be able to display data from the database in the events table in a partial view if a certain boolean field is true.
This is my partial view:
@model IEnumerable<TheBigEvent.Models.RecommendedEvents>
<table>
<tr>
<td>
@Html.DisplayNameFor(model => model.Event_Name)
</td>
<td>
@Html.DisplayNameFor(model => model.Event_Date)
</td>
</tr>
<tr>
@foreach (var item in Model) {
<td>
@Html.DisplayFor(modelItem => item.Event_Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Event_Date)
</td>
}
</tr>
</table>
This is my controller
public ActionResult _RecommendedEvents()
{
var recommendedevents = from Events in db.Database1
select Events;
recommendedevents = recommendedevents.Where(s => s.Recommended.Equals(true));
return PartialView("_RecommendEvents", recommendedevents);
}
And the Code for displaying the partialview
@Html.Partial("_RecommmndedEvents")
This is the error I am receiving
[EDIT]
public ActionResult _RecommendedEvents(RecommendedEvents model)
{
model = new RecommendedEvents();
var recommendedevents = from Events in db.Database1
select Events;
recommendedevents = recommendedevents.Where(s => s.Recommended.Equals(true));
return View(model);
}