ASP.NET MVC WebGrid添加标头

时间:2013-12-30 19:41:01

标签: c# asp.net-mvc header webgrid

如何将包含空格的标题列名添加到我的asp.net mvc webgrid?有人会对此提出一些想法吗?

 var str= "ProjectID,ProjectTitle,ProjectDescription";
 var headers = "Project ID,Project Title,Project Description";

    string[] columns = str.Split(',');
    string[] hdrs = headers.Split(',');

    var cols = new List<WebGridColumn>();
    foreach (var column in columns)
    {
        cols.Add(grid.Column(column));
    }

    @grid.GetHtml(columns: cols)

1 个答案:

答案 0 :(得分:1)

cols.Add(grid.Column(columnName: "column", header: "Column Name With Spaces"));