Webgrid MVC3-处理列的空值-ASP.NET [英] Webgrid MVC3- Handling Null Values for the columns-ASP.NET

查看:55
本文介绍了Webgrid MVC3-处理列的空值-ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理Web网格中列的空值?

How do I handle null value for columns in the web grid?

我正在使用Webgrid使用MVC3 asp.NET Grid在Webgrid中显示记录.

I am using the webgrid for displaying the records in a webgrid using MVC3 asp.NET Grid.

  var grid = new WebGrid(source: Model,selectionFieldName:"SelectedRow",rowsPerPage: 10, canPage: true, canSort: true, defaultSort: "Absentee.Name");
     @grid.GetHtml(grid.Column("AbsEnd", "AbsEnd"))

如果AbsEnd为Null.我该如何处理才能在该列中显示自定义字符串.点赞值不存在.

If the AbsEnd is Null. How do I handle this to display a custom string in that column. Like value does not exist.

推荐答案

对不起,不要误导您:但这是使其正常运行的方法:

Sorry not to Mislead you: but this is the way to get it working:

 grid.Column("Absend", format: (item)=> string.IsNullOrEmpty(item.AbsEnd)?string.Empty:item.AbsEnd),

谢谢

这篇关于Webgrid MVC3-处理列的空值-ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆