C#mvc3 Actionlink未在URL中发送参数
我对MVC3和Actionlink有一些问题。我正在使用从我的模型传递的数据动态地构建一个C#mvc3 Actionlink未在URL中发送参数,c#,asp.net-mvc-3,C#,Asp.net Mvc 3,我对MVC3和Actionlink有一些问题。我正在使用从我的模型传递的数据动态地构建一个HTML ActionLink 他认为: @for (int i = 0; i < Model.CountriesList.Count; i++) { <li class="sub">@Html.ActionLink(Model.CountriesList[i].countryname, "PageSub", new {
HTML ActionLink
他认为:
@for (int i = 0; i < Model.CountriesList.Count; i++)
{
<li class="sub">@Html.ActionLink(Model.CountriesList[i].countryname,
"PageSub", new { PageID = Model.PageNo,
countryid = Model.CountriesList[i].countryid
})</li>
}
当我直接输入时,我需要它在下面工作:
http://localhost/Pages/PageSub?PageID=136&countryid=196
这是我的控制器操作结果,它指向:
public ActionResult PageSub(int? PageID, int? countryid)
{
}
我已使用开发人员工具检查了代码,链接已按预期构建:
<li class="sub">
<a href="/Pages/PageSub?PageID=136&countryid=196">
</li>
有没有人有过类似的问题?如有任何建议,将不胜感激。谢谢试试这个:
@Html.ActionLink(Model.CountriesList[i].countryname, "PageSub", "Pages", new { PageID = Model.PageNo, countryid = Model.CountriesList[i].countryid }, null)
你可能刚刚错过了,但它不应该是“i
@Html.ActionLink(Model.CountriesList[i].countryname, "PageSub", "Pages", new { PageID = Model.PageNo, countryid = Model.CountriesList[i].countryid }, null)