本文介绍了如何解决这个问题显示我的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 hi 这是我的代码 hithis is my code using (DBNezamEntities DBNezamEntitie = new DBNezamEntities()) { PersianCalendar persiancalandar = new PersianCalendar(); var Query = from Newes in DBNezamEntitie.News select new { Newes.Title, Newes.Summary, HasbinUpdate = (persiancalandar.GetYear(Newes.UpdateDateTime).ToString() + "/" + persiancalandar.GetMonth(Newes.UpdateDateTime).ToString() + "/" + persiancalandar.GetDayOfMonth(Newes.UpdateDateTime).ToString() + " " + persiancalandar.GetHour(Newes.UpdateDateTime).ToString() + ":" + persiancalandar.GetMinute(Newes.UpdateDateTime).ToString() + ":" + persiancalandar.GetSecond(Newes.UpdateDateTime).ToString() + "" + persiancalandar.GetEra(Newes.UpdateDateTime).ToString()).ToString(), Groupes = Newes.Genre.Name }; GridView1.DataSource = Query; GridView1.DataBind(); } 并给我这个错误: 错误图片请点击 推荐答案 using (DBNezamEntities DBNezamEntitie = new DBNezamEntities()) { PersianCalendar persiancalandar = new PersianCalendar(); var Query = from Newes in DBNezamEntitie.News.AsEnumerable() // add AsEnumerable() select new { Newes.Title, Newes.Summary, HasbinUpdate = (persiancalandar.GetYear(Newes.UpdateDateTime).ToString() + "/" + persiancalandar.GetMonth(Newes.UpdateDateTime).ToString() + "/" + persiancalandar.GetDayOfMonth(Newes.UpdateDateTime).ToString() + " " + persiancalandar.GetHour(Newes.UpdateDateTime).ToString() + ":" + persiancalandar.GetMinute(Newes.UpdateDateTime).ToString() + ":" + persiancalandar.GetSecond(Newes.UpdateDateTime).ToString() + "" + persiancalandar.GetEra(Newes.UpdateDateTime).ToString()).ToString(), Groupes = Newes.Genre.Name }; GridView1.DataSource = Query; GridView1.DataBind(); } 希望它有所帮助。 谢谢。hope it helps.Thanks. 这篇关于如何解决这个问题显示我的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-22 18:28