Closed ghost closed 8 years ago
What does the TicketIndexViewModel
looks like? You are using it as a model in your view, so I don't know if it has property State
Also, please make sure to submit formatted questions. It's really painful to read something like what you wrote. There is a "Preview" tab when you create an issue or reply to one.
sorry for the formating and here is the TicketIndexViewModel:
public class TicketIndexViewModel
{
public IEnumerable<PSW.ViewModels.TicketIndexDetailViewModel> Tickets { get; set; }
public TicketState CurrentSelectedState { get; set; }
public Dictionary<TicketState, int> NumberOfTicketsPerState { get; set; }
}
You've got the @Html.Bootstrap().DropDownListFromEnum("State")
in a foreach loop
.
Having it assigned to property "State" will make it try to bind to the un-existing property "State" on "TicketIndexViewModel".
Use helper .DropDownListFromEnumFor(model => model...)
to avoid these issues. You'll get intellicense hint with all the props that you can use. In this case you'll have to do some trickery with a for loop. Quick untested code:
@for (var i, l = Model.Tickets.Count(); i < l; i++)
{
<tr>
<td>@Html.Bootstrap().ActionLink(@ticket.Key, "Edit").RouteValues(new { ticketID = @ticket.TicketID })</td>
<td>@Html.Bootstrap().ActionLink(@ticket.Summary, "Edit").RouteValues(new { ticketID = @ticket.TicketID })</td>
<td>@ticket.ReporterName</td>
<td>@ticket.AssigneeName</td>
<td>@Html.Bootstrap().DropDownListFromEnumFor(model => model.Tickets[i].State)</td>
</tr>
}
I don't remember how these things are done exactly, but there are plenty of articles in regard to binding inputs inside a for loop to the view model.
thanks a lot! That was the problem, now i know how to fix such errors.. TwitterBootstrapMVC is worth every cent!
Glad I could point you in the right direction.
Hi Dmitry,
can you help me with this task: What i have:
the ViewModel
the view:
At the very bottom of the foreach loop i need to Show the value of the State Enum. I get the Exception:
The debugger shows a value: