1

我有一個從缺陷代碼列表構建的表。局部視圖可以用來做Ajax項目更新嗎?

每行的一部分可以通過提交按鈕加載子表項嗎?

樣品表:

<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> 
+0

你可以添加更多的細節,如你正在使用的模型?據我所知,你需要在你的表裏面有一個局部表單,有兩個不同的模型,一個顯示錶格的前兩列和另一個,但爲什麼你有兩個按鈕foreach行(保存和保存錯誤)? – JOBG 2009-12-02 01:25:35

+0

只會有一個按鈕,保存。最後一列將是驗證摘要/驗證錯誤。如果這還沒有顯示出我想要完成的事情,我可以在明天的工作中添加更多細節。 – Maslow 2009-12-02 04:06:59

回答

0
<% foreach (var item in Model.DefectCodes) { %> 

    <tr> 
     <% using (Ajax.BeginForm("Create", new AjaxOptions())) 
      {%> 

     <!--should be easy like this!--><!--ur codeid here--> 
     <%=Html.HiddenFor(modelItem => item.codeid)%> 

     <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> 

它只是解決了烏拉圭回合的隱藏價值!問題..

你不需要把它放到TD因爲你希望它被隱藏,所以它仍然會得到你的價值,但不會顯示在窗體中,或在表或視圖..這種方式你可以保留3 TD並獲得比表格上顯示的更多的價值。