我已将UserID
传递给表格,如代码所示:
查看
@foreach (var user in Model.RIROUsers)
{
<tr>
<td class="text-center">@(user.FirstName + " " + user.LastName)</td>
<td><a href="a href="~/Views/RIRO/id=@user.UserID" class="btn btn-xs btn-primary" data-toggle="modal" data-target="#exampleModal" data-id="@user.UserID">View Details</button></a>
</tr>
}
模态
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="form-group col-md-4 col-md-offset-2">
<label for="">* Address</label>
<input type="text" class="form-control input-sm" value="">
<label for="">* Birthday</label>
<input type="text" class="form-control input-sm" value="">
<label for="">* Contact</label>
<input type="text" class="form-control input-sm" value="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
控制器
public ActionResult Index()
{
var vm = new RIROViewModel();
vm.RIROUsers = new List<ResourceViewModel>();
foreach (var user in db_RIRO.sp_GetAllRIRORoster())
{
vm.RIROUsers.Add(new ResourceViewModel()
{
EID = user.EID,
FirstName = user.FirstName,
LastName = user.LastName,
EmployeeType = user.EmployeeType,
ProjectName = user.ProjectName,
JobTitle = user.JobTitle,
Level = user.CareerLevel,
ACNRollOn = user.HireDate,
ManagerName = user.Manager,
LeadName = user.Supervisor,
UserID = user.UserID
});
}
return View(vm);
}
现在,当我点击View Details
时,我希望用户的详细信息显示在模态上。对此最好的方法是什么?我正在考虑创建另一个存储过程来检索用户的详细信息并将其显示在模态上。但是我该怎么做呢?
编辑1:将按钮更改为a href=~/Views/RIRO/id=@user.UserID