我想在下拉列表中创建`@ Html.ActionLink(model.country,“Details”,“Country”)'作为选项..因为以后,不同角色的访问将看到不同的链接...在Html.ActionLink中创建一个动态链接文本和链接()
控制器
public ActionResult Index()
{
CountryList = db.CountryListTable.Select(x => x.countryName).ToList();
ViewBag.ctr = CountryList;
return View();
}
查看
@foreach (var item in @ViewBag.ctr)
{
<span>@item</span>
<span>
@* @Html.ActionLink((string)@item, "Details", "Country"); *@ @* this part throw error due to null *@
</span>
<br />
}
@item
不空...我不知道为什么它扔空值时与封装@html.ActionLink
...
仅供参考,使用.netFramework 4.0和MVC4 IM ...
我很新的MVCň.netFramework
谢谢!第二种方法真的可以工作! 只是为其他reffrence,我认为第一个犯规,因为第一个参数必须是串... – zahrin
进出口新的堆栈......已经起来投票,但似乎那里有它另外一个要求...... 妮甚至不知道如何标记这个职位为解决.... – zahrin
你已经做了 –