モデルからいくつかの値を渡し、選択した値/項目を Html.ActionLink メソッドを介してコントローラーに渡したいのですが、適切な方法が見つかりません。以下にコードを示します-
意見:
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="row">
<div class="span3">
<div class="text-left">@Html.LabelFor(model => model.EntryId)</div>
</div>
<div class="span3">
<div class="text-left">
@Html.DisplayFor(model => model.EntryId)
@Html.HiddenFor(model => model.EntryId)
</div>
</div>
<div class="span3">
<div class="text-left">@Html.LabelFor(model => model.EntryDate)</div>
</div>
<div class="span3">
<div class="text-left">
@Html.DisplayFor(model => model.EntryDate)
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Check Information</legend>
<div class="row">
<div class="span3">
<div class="text-left">@Html.LabelFor(model => model.Check.CheckId)</div>
</div>
<div class="span3">
<div class="text-left">
@Html.DisplayFor(model => model.Check.CheckId)
@Html.HiddenFor(model => model.Check.CheckId)
</div>
</div>
<div class="span3">
<div class="text-left">@Html.LabelFor(model => model.Check.CheckTitle)</div>
</div>
<div class="span3">
<div class="text-left">@Html.DisplayFor(model => model.Check.CheckTitle)</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Comments</legend>
<div class="span4">
@Html.ActionLink("Add Comment", "AddComment", new { Model.EntryId })
@Html.ActionLink("View All Comments", "ViewAllComments", new { Model.Check.CheckId })
</div>
<div>
<table class="table table-bordered">
<tr>
<th>
Serial
</th>
<th>
Comment
</th>
<th>
Date
</th>
<th>
Status
</th>
<th>
</th>
</tr>
@for (int i = 0; i < Model.CheckCommentsList.Count; i++)
{
<tr>
<td>
@Html.DisplayFor(modelItem => Model.CheckCommentsList[i].Serial)
@Html.HiddenFor(modelItem => Model.CheckCommentsList[i].Serial)
</td>
<td>
@Html.DisplayFor(modelItem => Model.CheckCommentsList[i].Comment)
@Html.HiddenFor(modelItem => Model.CheckCommentsList[i].Comment)
</td>
<td>
@Html.DisplayFor(modelItem => Model.CheckCommentsList[i].CommentDate)
@Html.HiddenFor(modelItem => Model.CheckCommentsList[i].CommentDate)
</td>
<td>
@Html.DropDownListFor(modelItem => Model.CheckCommentsList[i].CommentStatus, new SelectList(Model.CommentStatusList, Model.CheckCommentsList[i].CommentStatus.ToString()), new {@id="ddlCommentStatus"})
@Html.ValidationMessageFor(model => Model.CheckCommentsList[i].CommentStatus)
@*@Html.HiddenFor(modelItem => Model.CheckCommentsList[i].CommentStatus)*@
</td>
<td>
@Html.ActionLink("Update Status", "UpdateCommentStatus", new { Model.EntryId, Model.CheckCommentsList[i].Serial, Model.CheckCommentsList[i].CommentStatus, Model.Check.CheckId })|
@Html.ActionLink("Delete", "DeleteComment", new { Model.CheckCommentsList[i].Serial, Model.EntryId })
</td>
</tr>
}
</table>
</div>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
コントローラ:
public ActionResult UpdateCommentStatus(string entryId, int serial, string status, string checkId)
{
var securityInformation = new SecurityInformation();
securityInformation.MemberId = (string)Session["MemberId"];
if (string.IsNullOrEmpty(securityInformation.MemberId))
{
return RedirectToAction("LogIn", "MemberLogIn");
}
var commentStatus = (CommentStatus)Enum.Parse(typeof (CommentStatus), status);
new CheckDataManager().UpdateCheckDataCommentStatus(entryId, serial, commentStatus);
return RedirectToAction("ViewAllComments", new { checkId });
}
CommentStatus は Enum であることに注意してください。コントローラーのステータス変数に対して常に null を取得しています。誰かがそれを行う方法を教えてもらえますか。JQueryが解決策である場合、私はJQueryが初めてなので、例を挙げてください。