我有一个看起来像的视图模型
public class BusinessUnitDetail
{
public Guid Id { get; set; }
public string Name { get; set; }
public LicensesDetails LicensesDetails { get; set; }
public RepresentativeDetails RepresentativeDetails { get; set; }
}
public class LicensesDetails
{
public string BusinessUnitName { get; set; }
public List<LicensesVM> Licenses { get; set; }
}
public class RepresentativeDetails
{
public string BusinessUnitName { get; set; }
public List<RepresentativeVM> Representatives { get; set; }
}
目前,我的视图包含两个表格,显示List of Representative和List of Licenses。这是视图,很长,但无论如何
@{
ViewBag.Title = "BusinessUnitDetails";
Layout = "~/Views/shared/_BootstrapLayout.basic.cshtml";
int snor = 1;
int snol = 1;
}
<fieldset>
<legend>@Model.Name <small>Representatives</small></legend>
</fieldset>
<table class="table table-striped table-hover table-bordered">
<caption></caption>
<thead>
<tr>
<th>S.No</th>
<th>Name</th>
</tr>
</thead>
@foreach (var entry in Model.RepresentativeDetails.Representatives)
{
<tr>
@*@Html.HiddenFor(m=>entry.BusinessUnitId)*@
<td>@(snor++)</td>
<td>@entry.UserName</td>
<td>
<div class="btn-group" >
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
Action<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>@Html.ActionLink("Details", "RepresentativeDetails",routeValues:new{entry.BusinessUnitId})</li>
</ul>
</div>
</td>
</tr>
}
</table>
<fieldset>
<legend>@Model.Name <small>Licenses</small></legend>
</fieldset>
<table class="table table-striped table-hover table-bordered">
<caption></caption>
<thead>
<tr>
<th>S.No</th>
<th>Kind</th>
</tr>
</thead>
@foreach (var entry in Model.LicensesDetails.Licenses)
{
<tr>
@* @Html.HiddenFor(m=>entry.BusinessUnitId)*@
<td>@(snol++)</td>
<td>@entry.LicenseName</td>
<td>
<div class="btn-group" >
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
Action<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>@Html.ActionLink("Details", "LicenseDetails",routeValues:new{entry.BusinessUnitId})</li>
</ul>
</div>
</td>
</tr>
}
</table>
当我单击许可证表中某行的详细信息操作时,我希望它会将我重定向到中所述的操作方法,但事实并非如此。我单击详细信息操作时的路线是LicenseDetails
Html.ActionLink
Customer/businessunit/LicenseDetails?BusinessUnitId=25c70a1d-0ed5-406f-8cae-1c6c1bf7d0da
我不知道LicenseDetails?BusinessUnitId=部分是如何生成的,以及为什么该操作不转发到控制器中的 LicenseDetails 方法。我该怎么做,当我单击第二个表中的详细信息操作时,我会被转发到正确的控制器操作,该操作具有正确的 Guid id 知道吗?
编辑 1:许可证详细信息操作方法
public ActionResult LicenseDetails(Guid licenseId)
{
var licenseDetails = _businessUnitRepository.GetLicenseDetail(licenseId);
return View(licenseDetails);
}