gpt4 book ai didi

asp.net-mvc-3 - 仅显示日期格式并在 MVCContrib 网格中保持排序 AZ

转载 作者:行者123 更新时间:2023-12-01 10:06:39 24 4
gpt4 key购买 nike

我使用以下 LINQ 创建网格模型:

...
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 根本不起作用。

有什么线索吗?谢谢!!!

最佳答案

尝试使用

col
.For(c => c.EndDate.ToLongDateString())
.Named("End Date")
.Attributes(@class => "row")
.HeaderAttributes(@class => "head");

关于asp.net-mvc-3 - 仅显示日期格式并在 MVCContrib 网格中保持排序 AZ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9677434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com