Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Filename for @Html.EditorForModel()?
    primarykey
    data
    text
    <p>so I have the following code:</p> <pre><code>@model IEnumerable&lt;My_School_Book.Models.Mark&gt; @{ ViewBag.Title = "Marks"; } &lt;div class="row-fluid"&gt; &lt;h1&gt;Assignment Marks:&lt;/h1&gt; @using (Html.BeginForm("Marks", "Assignment", FormMethod.Post, new { @class = "form-horizontal" })) { &lt;table class="table table-bordered"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Student&lt;/th&gt; &lt;th style="width: 50px;"&gt;Mark &lt;/th&gt; &lt;th style="width: 50px;"&gt;Total &lt;/th&gt; &lt;th style="width: 50px;"&gt;Weight&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; @Html.EditorForModel() &lt;/tbody&gt; &lt;/table&gt; &lt;div class="form-actions"&gt; &lt;button type="submit" class="btn btn-primary"&gt;&lt;i class="icon-checkmark"&gt;&lt;/i&gt;&amp;nbsp;Save&lt;/button&gt; &lt;a href="@Url.Action("Index", "Assignment")" class="btn btn-primary"&gt;&lt;i class="icon-back"&gt;&lt;/i&gt;&amp;nbsp;Cancel&lt;/a&gt; &lt;/div&gt; } &lt;/div&gt; </code></pre> <p>As you can see my Model being passed into the view is an IEnumerable of the Model Mark.</p> <p>Now I have a EditorTemplate under the Views/Shared folder called Mark:</p> <pre><code>@model My_School_Book.Models.Mark &lt;tr&gt; &lt;td&gt;@Model.Student.FullName&lt;/td&gt; &lt;td&gt; @Html.TextBoxFor(model =&gt; Model.Grade, new { @class = "span12", @style = "min-height: 20px;", @maxlength = "5" }) &lt;/td&gt; &lt;td&gt; @Model.Assignment.Total &lt;/td&gt; &lt;td&gt;@Model.Assignment.Weight&lt;/td&gt; &lt;/tr&gt; </code></pre> <p><strong>My question is</strong>, can I rename my EditorTemplate file from Mark to AssignmentMarks? I'd like it to be more specific instead of a generic name called Marks.</p> <p>Edit:</p> <p>Inside my MarkRepository.cs</p> <pre><code> public IEnumerable&lt;Mark&gt; GetAllByAssignmentID(Guid id) { return context.Marks.Where(m =&gt; m.AssignmentID == id); } </code></pre> <p>Inside my AssignmentController.cs</p> <pre><code> public ActionResult Marks(Guid id) { IEnumerable&lt;Mark&gt; Marks = markRepository.GetAllByAssignmentID(id).ToList(); return View(Marks); } [HttpPost] public ActionResult Marks(IEnumerable&lt;Mark&gt; viewModel) { if (ModelState.IsValid) { } return View(viewModel); } </code></pre> <p>Inside my Marks.cshtml</p> <pre><code> @Html.EditorForModel("Mark", "AssignmentMark") </code></pre> <p>Inside my AssignmentMark.cshtml</p> <pre><code>@model My_School_Book.Models.Mark &lt;tr&gt; &lt;td&gt;@Html.DisplayTextFor(model =&gt; model.Student.FullName)&lt;/td&gt; &lt;td&gt;@Html.TextBoxFor(model =&gt; model.Grade, new { @class = "span12" })&lt;/td&gt; &lt;td&gt;@Html.DisplayTextFor(model =&gt; model.Assignment.Total)&lt;/td&gt; &lt;td&gt;@Html.DisplayTextFor(model =&gt; model.Assignment.Weight)&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>The error I receive on my View is now: </p> <pre><code>System.Data.Entity.DynamicProxies.Assignment_7EDE7AD8477AB363802A036747CD8A8B259C6CD72DCEF587A2B0FBEDC7B2DCE1System.Data.Entity.DynamicProxies.Assignment_7EDE7AD8477AB363802A036747CD8A8B259C6CD72DCEF587A2B0FBEDC7B2DCE1System.Data.Entity.DynamicProxies.Assignment_7EDE7AD8477AB363802A036747CD8A8B259C6CD72DCEF587A2B0FBEDC7B2DCE1System.Data.Entity.DynamicProxies.Assignment_7EDE7AD8477AB363802A036747CD8A8B259C6CD72DCEF587A2B0FBEDC7B2DCE1 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload