我的 viewmodel 看起来像
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; }
}
目前,我的观点包含两个表格,其中显示了代表名单和许可证列表。 这是视图,很长但是无论如何
@{
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
操作方法,如{{1}中所述但是它没有。
单击详细信息操作时的路径是
Html.ActionLink
我不知道如何生成 LicenseDetails?BusinessUnitId = 部分,以及该操作为何不转发到控制器中的LicenseDetails方法。 我可以这样做,当我点击第二个表格中的详细信息操作时,我会转发到正确的控制器操作,其中有适当的Guid ID 有什么想法吗?
编辑1:许可证明细行动Methode
Customer/businessunit/LicenseDetails?BusinessUnitId=25c70a1d-0ed5-406f-8cae-1c6c1bf7d0da
答案 0 :(得分:0)
尝试使用这种语法:
@Html.ActionLink("Details", "LicenseDetails", new { licenseId = entry.BusinessUnitId })
希望它有所帮助。
答案 1 :(得分:0)
您的ActionLink似乎适合某些路线。使用controllername:
更强烈地键入它@Html.ActionLink("Details", "LicenseDetails", "Home", new { licenseId = entry.BusinessUnitId }, null)