I posted a question earlier which was marked a duplicate since it is somewhat similar to an existing answered-question. In my original question question I explained the problem that I had.
Now, I am trying to use my take away from the question that has the answer "i.e.Post an HTML Table to ADO.NET DataTable" and trying to implement it. The main different between what I am doing and what the answer have is that I encapsulate multiple ViewModels in a presentation class because the view has multiple forms. Additionally, I use use DropDownListFor
which requires a SelectItem
list that depends on another property in my presenter class.
Here is what I have done
I created a template view for my grid rows like this
@model Proj.ViewModels.UserProfileAccessUserToClientsViewModel
<tr>
<td>
@Html.HiddenFor(m => m.ClientId)
</td>
<td>
Menu Goes here -- Still to do since I don't know how to pass SelectItem to this view
</td>
<td>
@Html.TextBoxFor(m => m.JoinedAt, new { @class = "form-control date-picker small-input" })
</td>
<td>
@Html.RadioButtonFor(m => m.IsActive, true) Allowed
</td>
<td>
@Html.RadioButtonFor(m => m.IsActive, true) Not Allowed
</td>
</tr>
Then in one of the form where I want to display the table, I do this
@model Proj.Presenters.UserProfilePresenter
<div class="panel panel-default">
<div class="panel-heading">User To Client Association</div>
<table class="table table-condensed table-valign-text" id="UserToClientRelationTable">
<thead>
<tr>
<th>Client</th>
<th>Default Team</th>
<th class="text-center">Join At</th>
<th colspan="2" class="text-center">Status</th>
</tr>
</thead>
<tbody>
@Html.EditorFor(m => m.Access.UserToClients)
</tbody>
<tfoot>
<tr>
<td colspan="5" class="text-center">
<ul class="pagination pagination-sm pager" id="UserToClientRelationTablePager"></ul>
</td>
</tr>
</tfoot>
</table>
</div>
Now, when I run my code there are no rows for my tables. Perhaps, I am not including my template in my main view. But also not sure how would I do that.
Questions
How can I correctly use my edit template to display the rows?
How can I pass a variable to my edit template which is needed to generate the SelectItem
list for the DropDownList?