【问题标题】:Displaying a boolean as a Yes/No within a Webgrid在 Webgrid 中将布尔值显示为是/否
【发布时间】:2015-07-13 18:52:21
【问题描述】:

我正在尝试使用 Webgrid 并且可以显示数据,但 bool 值 是我遇到问题的地方。我只想显示 Yes 或 No 而不是 true 或 false。

 webGridColumns.Add(new WebGridColumn 
{ ColumnName = "IsActive", CanSort = true, Header = "Is Active" });

这样做的正确方法是什么。请给点意见

【问题讨论】:

    标签: asp.net-mvc-4 webgrid


    【解决方案1】:

    经过一番搜索,我自己找到了答案。

    如果有人遇到这个问题,我希望它能帮助他们。

    webGridColumns.Add(new WebGridColumn { 
        ColumnName = "IsActive",
        Header = "Is Active",
        CanSort = true,
        Format= @<text>
            @(item.IsActive ? "Yes" : "No" )
        </text>}
    );
    

    【讨论】:

      猜你喜欢
      • 2012-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      • 2021-03-24
      相关资源
      最近更新 更多