如何将ID传递给控制器​​并使用它来显示模态数据

时间:2018-05-10 16:16:17

标签: asp.net asp.net-mvc

我已将UserID传递给表格,如代码所示:

enter image description here

查看

@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

0 个答案:

没有答案