我使用MVC-5和C#动态地将列添加到Web网格中,当网格渲染一切看起来很好但列标题不能用作动作链接。代码有两个版本,两者都呈现,但不作为Action Links。 谢谢你的帮助。
3 6 9 12 15
18 21 24 27 30
除了列标题不是我希望的Action Links之外,所有内容似乎都能正确呈现。我也尝试了第二段代码,结果相同。 谢谢您的帮助。 我意识到看到整个视图是至关重要的,因为我正在动态构建网格。
cols.Add(grid.Column(Model.DictionaryList[i].Keys.ElementAt(i).ToString(), Model.DictionaryList[i].Keys.ElementAt(i).ToString(),
format: @<Text>@Html.ActionLink((string)Model.DictionaryList[i].Values.ElementAt(i).ToString(), "Select_MSPart_Search",
"MaterialSupply", new
{
id = ViewData["id"],
type = 1,
SearchFilter = Model.DictionaryList[i].Keys.ElementAt(i).ToString(),
SearchValue = "",
rowsPerPage = 7
})</Text>, style: "column-action"));
cols.Add(grid.Column(header: Model.DictionaryList[i].Keys.ElementAt(i).ToString(),columnName: Model.DictionaryList[i].Keys.ElementAt(i).ToString(),
format: (item) => new HtmlString(Html.ActionLink((string)Model.DictionaryList[i].Values.ElementAt(i).ToString(), "Select_MSPart_Search",
"MaterialSupply", new
{
id = ViewData["id"],
type = 1,
SearchFilter = Model.DictionaryList[i].Keys.ElementAt(i).ToString(),
SearchValue = "",
rowsPerPage = 7
},null).ToHtmlString()), style: "column-action"));
答案 0 :(得分:0)
我发现了问题。我忘记了列:@ grid.GetHtml上的cols。 谢谢