我有
@Html.ActionLink("Remove 1034,1035,1036","RemoveSelected")
现在我想从Controller设置每个id
例如:
@Html.ActionLink(ViewBag.RemoveSelectedTitle,"RemoveSelected") //this is not work // GET: /TabMaster/ public ActionResult Index() { ViewBag.RemoveSelectedTitle = "100,101,102"; return View(_tabmasterService.GetTabMasterList(10,1)); }
解决方法
您需要将RemoveSelectedTitle转换为字符串.当您使用Viewbag时,这是一个动态对象,并且不知道RemoveSelectedTitle是一个字符串. ActionLink应该是这样的:
@Html.ActionLink((string)ViewBag.RemoveSelectedTitle,"RemoveSelected")