MVC 1の新機能です。
私のプロジェクトでは、 IList をモデルに割り当て、 forloop を使用して Textbox 、 dropdox などに割り当てています...ユーザーは要件に従って値を変更できます。私が欲しいのは、ユーザーがページの上部にある [すべて保存] ボタンをクリックしたときに、ILIST の形式で aspx ページに存在する値を取得する方法です。
ここに、フォームの入力に使用するコードがあります....
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<% using (Html.BeginForm("MyController", "EditCopyRestaurantMealRate", FormMethod.Post, new { id = "frmEditCopyRestaurantMealRate" }))
{ %>
<%= Html.Submit("Save All Services", ApplicationPermissions.ManageContract, new { name = "submitButton" })%>
<table width="100%" class="edit_restaurant_form">
<col width="19%" />
<col width="30%" />
<col width="19%" />
<col width="*" />
foreach (var item in Model)
{
%>
<tr>
<th>
<label for="DateFrom">
Effective from:</label> <label class="mandatory">* </label>
</th>
<td>
<% string dtFrom = "";
dtFrom = item.Datefrom.ToString("dd-MMM-yyyy");
%>
<%= Html.TextBox("DateFrom", dtFrom)%>
</td>
<th>
<label for="DateTo">
Effective to:</label> <label class="mandatory">* </label>
</th>
<td>
<% string dtTo = "";
dtTo = item.Dateto.ToString("dd-MMM-yyyy");
%>
<%= Html.TextBox("DateTo", dtTo)%>
</td>
</tr>
<% }
%>
ここにコントローラーコードがあります。
public ActionResult MyController(string submitButton, IList<CMS.Model.VcmsRestaurant> AddendumMealRates)
{
// Need to receiv all value in list which is edited
return View(@"~\index.aspx", AddendumMealRates);
}
MyController
ユーザーがページで編集する値を取得するにはどうすればよいですか?