[英]ASP.NET ToList<> Cast bool to string
我在这里有此代码:
GridView gv = new GridView();
gv.DataSource = db.Data.ToList().Where(model => model.closed == false);
而且效果很好。 我想知道是否可以将列表中的项目从bool转换为string? 就像是
gv.DataSource = db.Data.ToList().Where(model => model.closed == false).Cast(convert model.closed to string)
将结果投影到匿名类型并在那里进行转换。
GridView gv = new GridView();
gv.DataSource = db.Data.ToList().Where(model => !model.closed)
.Select(m => new
{
Closed = Convert.ToString(m.Closed),
//... Rest of the fields.
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.