次のコードでは、model.StartDate にある完全な DateTime を提供しています。
@Html.DisplayFor(model => model.StartDate.ToString("hh:mm tt"),
CultureInfo.CreateSpecificCulture("hu-HU"));
私の目標は、完全な DateTime を取ることです
8/30/2012 11:33:48 AM
および表示のみ
11:33:48 AM
ただし、次のエラーが表示されます。
Templates can be used only with field access, property access,
single-dimension array index, or single-parameter custom indexer expressions.
なぜこのエラーが発生するのですか?
注: このドキュメントを参照して、DateTime の .ToString をフォーマットしました: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx