질문과 대답을 생성하는 방법을 사용하고 있습니다. 모든 질문이 표시되고이 질문의 답변이 여기에서 볼 수 있듯이 DDL에 저장됩니다.컨트롤러에서 표준 드롭 다운 목록의 값을 얻습니다.
public string GenerateHtmlCode()
{
string result = string.Empty;
List<ExecutiveOfficer> executiveOfficers = executiveOfficerRepository.GetAll().ToList();
List<Indicator> indicators = indicatorRepository.GetAll().ToList();
foreach (ExecutiveOfficer executiveOfficer in executiveOfficers)
{
result += "<div style='width:100%;float:right;'><span>" + executiveOfficer.ExecutiveOfficerText +
"</span><span style='float:left'>" +
GenerateAnswer(indicatorRepository.FindBy(i => i.ExecutiveOfficerId == executiveOfficer.Id
).ToList(), executiveOfficer.Id) + "</span></div>";
}
return result;
}
에서
내 당신이 여기에서 볼 수 있듯이 내가 viewbag
에 문자열을 전달 컨트롤러의 방법을 만들 :
[HttpGet]
public ActionResult Create(int preliminaryId)
{
ViewBag.preliminaryId = preliminaryId;
ViewBag.pageGenarator = objScoreRepository.GenerateHtmlCode();
// List<ExecutiveOfficer> executiveOfficer = objScoreRepository.GetAll().ToList();
//ViewBag.executiveOfficerName = new SelectList(executiveOfficer, "Id", "ExecutiveOfficerText");
return View("Create");
}
내 HTML 코드 :
</span><span style='float:left'><select id='1'><option value='value1'>displaytext</option></select></span>
당신이
id=1
가치
value1
및
displaytext
에 문제는 내
httppost create controller
에서 생성되는 위의 코드에서 볼 수 있듯이
내가 말은 내가 1
말은 questionId
그 값을 얻을 필요가 value1
.I 그것을 봤과 내가 뭔가를 발견 약 form collection
하지만 나는 어떻게 할 수 있을지 모르겠다.
모든 아이디어는 높이 평가됩니다.
안부
public ActionResult Create(FormCollection formCollection)
{
??????get value and question id to save
return RedirectToAction("Create", "Score");
}
HTML을보기를 만듭니다
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_LayoutIdeaOtherPage.cshtml";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
@Html.Raw(ViewBag.pageGenarator)
<div class="buttonPossion">
<input type="submit" value="????? ???????" Class="buttonSave" />
</div>
}
당신은 참조하시기 바랍니다 수하게하여 html 코드 ...? –
@ V2Solutions-MSTeam 게시물을 업데이트했습니다. –
@ V2Solutions-MSTeam 티는 Dawid Dziadkiewicz 응답을 시도했지만 형식 컬렉션은 레코드를 반환하지 않습니다. –