MVC 모델을 통해 순환하면서 레코드 목록을 가지고 있습니다 (아래 코드의 "each"루프 참조).부트 스트랩 버튼이있는 목록에서 항목 ID를 일치시켜야합니다.
ActionLink가 있고 다른 페이지에 연결하는 대신 은을 클릭 한 레코드의 ID에 부트 스트랩 구성 요소를 연결하고 모달 폼을 표시 할 수 있기를 원합니다.
모달 양식 을 가져와 연결하는 방법을 알고 있습니다. 목록에서 필요한 모든 구성 요소에 ID 값을 연결하는 것을 제외하고는.
나는 다음과 같은 약 뭔가을 생각하고 있어요,하지만 난 사용하는 정확한 구성 요소의 도움이 필요하고 어떻게 클릭 된 레코드의 ID 값을 연결하는 방법. & htmlattributes 그냥 추측했다 routevalues와
ActionLink ...
어떤 도움을
@model IEnumerable<YeagerTechDB.Models.Category>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.CategoryDescription)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CategoryDescription)
</td>
<td>
@*insert a specific bootstrap component instead of actionlinks???*@
@*when component clicked, assoicate record id in list, bring up modal form and execute associated JS*@
@*if using just a button below, how do i associate the id of the item that was clicked?*@
<button type="button" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Edit
</button>
@Html.ActionLink("<span class='glyphicon glyphicon-edit'></span>", "Edit", "Edit", routeValues: new { id = item.CategoryID }, htmlAttributes: new { data_modal = "", @class = "btn btn-default" })
@*@Html.ActionLink("Edit", "Edit", new { id = item.CategoryID })*@
</td>
</tr>
}
@*bootstrap modal screen inserted here*@
@*have hidden id field in modal form*@
</table>
우수 제안 - 감사합니다! – sagesky36