【发布时间】:2010-12-22 04:40:18
【问题描述】:
我有一张根据缺陷代码列表构建的表格。
每行的一部分可以加载带有提交按钮的子表项吗?
示例表:
<table><tr>
<th>Code</th><th>Description</th>
<th>Impact to your customers</th>
<th>Impact to your associates</th>
<th>Save</th>
<th>Save Errors</th></tr>
前 2 列是从查找表中填充的,接下来的 3 列是一个表单,因此用户可以设置值或从以前的值更新它们。
我能否以某种方式让每行有 3 个 TD 项目一个单独的 Ajax 表单,其中 codeId 作为隐藏值嵌入?我的强类型视图会继承什么?外层会继承IEnumerable<DefectDTO>,部分视图会继承AssessmentDTO类型?
这是我正在尝试使用的实际表格:
<table>
<tr>
<th>
Code
</th>
<th>
Description
</th>
<th>
Document
</th>
<th>
Customer Contact Required for Resolution
</th>
<th>
AssociateSeverity
</th>
<th>
ShareholderSeverity
</th>
<th>
CustomerSeverity
</th>
<th>
RegulatorySeverity
</th>
<th>
RootCause
</th>
<th>
Investor Requirements*
</th>
</tr>
<% foreach (var item in Model.DefectCodes) { %>
<tr>
<% using (Ajax.BeginForm("Create", new AjaxOptions() ))
{%>
<td>
<%= Html.Encode(item.Code)%>
</td>
<td>
<%= Html.Encode(item.Description)%>
</td>
<% Html.RenderPartial("Create",null, ViewData); %><!-- This is where the form is -->
<% } %>
</tr>
<% } %>
</table>
【问题讨论】:
-
您可以添加更多详细信息,例如您正在使用的模型吗?据我了解,您的表格中需要一个部分表格,有两个不同的模型,一个显示前两列,另一个用于表格,但是为什么每行都有两个按钮(保存和保存错误)?
-
只有 1 个按钮,保存。最后一列是验证摘要/验证错误。如果这不能充分显示我想要完成的工作,我可以在明天的工作中添加更多细节。
标签: asp.net-mvc ajax partial-views asp.net-mvc-ajax asp.net-mvc-partialview