我對View
一個Kendo DropDownList
,我想它的DataTextField
值傳遞給Controller
,然後他們通過在另一View
標籤。雖然我可以將DataValueField
值傳遞給Controller
,但我無法傳遞DataTextField
值。我試圖應用不同的場景,但我不能。任何想法?另一方面,如果不可能,DataTextField
值是否應該再次填充到Controller
並返回到其他View
?如何通過劍道DropDownList的DataTextField值控制器
查看:
@model IssueViewModel
...
@Html.LabelFor(m => m.ProjectID)
@(Html.Kendo().DropDownList()
.Name("ProjectID")
.DataTextField("ProjectName")
.DataValueField("ProjectId")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetProjects", "Issue");
});
})
)
控制器:
public JsonResult GetProjects()
{
var projects = repository.Projects;
return Json(projects.Select(m => new { ProjectId = m.ID, ProjectName = m.Description }), JsonRequestBehavior.AllowGet);
}
/* I want to pass the DataTextField values to this
method and return them to the CreateManagement view */
public ActionResult Create(IssueViewModel issueViewModel)
{
return RedirectToAction("CreateManagement", issueViewModel);
}
@AmirHosseinMehrvarzi Selam Hossein。有任何答覆嗎? –
如果您在控制器上使用DataTextField而不是DataValueField,那麼爲什麼不像DataValueFields那樣枚舉DataTextField呢? –
@AmirHosseinMehrvarzi請你張貼一個示例代碼嗎?我真的嘗試了很多方法,但我認爲我犯了錯誤,不知道如何解決這個問題? –