当用户单击下拉列表的所选项目时,我需要获取子 id,并且人们告诉我,我需要在控制器和视图之间传递数据多次,我找到一个 ajax 代码将该 id 发布到控制器,但它返回 null。
这是执行此操作的正确方法吗?
我的看法 :
@using (Html.BeginForm())
{
<table class="table table-hover">
<tr>
<td>
@Html.Label("PersonalAdı")
</td>
<td>@Html.EditorFor(model => model.PersonalName)</td>
</tr>
<tr>
<td> @Html.Label("Departman")</td>
<td> @Html.EditorFor(model => model.PersonalDepartment)</td>
</tr>
<tr>
<td>@Html.Label("IseGirisTarihi")</td>
<td>@Html.EditorFor(model => model.IseGirisTarihi)</td>
</tr>
<tr>
<td>
@Html.DisplayNameFor(model => model.FormDetail.Form)
</td>
<td>
@Html.DropDownListFor(model => model.FormDetail.FormId,
Model.FormViewList)
</td>
</tr>
<tr>
<td>
@Html.DisplayNameFor(model => model.FormDetail.CheckListType)
</td>
<td>
@Html.DropDownListFor(model =>
model.FormDetail.CheckListTypeId, Model.checkLists, new
{@id="Selection",
@class = "drop-open" })
<td><button onclick="">Bolum Ekle</button></td>
</tr>
<tr>
<td colspan="2" style="padding-top:40px;">
<input type="submit" value="Save" class="btn btn-info" />
</td>
</tr>
</table>
<script src="~/Scripts/jquery-3.1.1.min.js"></script>
<script src="~/Content/js/open.js"></script>
}
我的控制器:
[HttpGet]
public ActionResult Add()
{
FormDetailViewModel model = new FormDetailViewModel();
foreach(Form item in formRep.List().ProcessResult)
{
FormList.Add(new SelectListItem { Value = item.FormId.ToString(), Text = item.TeslimEden });
}
foreach(Item item in itemRep.List().ProcessResult)
{
İtemList.Add(new SelectListItem { Value = item.ItemId.ToString(), Text = item.ItemDesc });
}
呼啦一阵风
相关分类