3
我用下面的LINQ创建网格模型:显示的日期格式只,并保持在MVCContrib排序AZ电网
...
var query = from a in GetUser()
select new UserModel
{
ID = a.ID,
StartDate = a.StartDate,
EndDate = a.EndDate,
StateName = a.State.StateName,
StateID = a.StateID,
City = a.City,
};
return query;
....
和HTML是
@Html.Grid(Model.PagedList).Columns(
col =>
{
col.For(c => c.StateName).Named("State").Attributes(@class => "row").HeaderAttributes(@class => "head");
col.For(c => c.City).Named("City").Attributes(@class => "row").HeaderAttributes(@class => "head");
col.For(c => c.StartDate).Named("Start Date").Attributes(@class => "row").HeaderAttributes(@class => "head");
col.For(c => c.EndDate).Named("End Date").Attributes(@class => "row").HeaderAttributes(@class => "head");
col.For(c => Html.ActionLink("Details", "Details", new { id = c.ID })).Named("View Details").HeaderAttributes(@class => "head").DoNotEncode();
}).Sort(Model.GridSortOptions).Attributes(@class => "grid")
的主要问题是如何显示只有DATE没有TIME部分?
我尝试了一些选项,但在某些情况下,我得到了错误,而在其他情况下,排序AZ根本不起作用。
任何线索? 谢谢!!!
试着看看这篇文章http://stackoverflow.com/questions/4679352/converting-datetime-format-using-razor – 2012-03-13 02:11:33