只在网页上显示日期

虽然在数据库中有data类型的数据来只显示日期,但是c#中只有datetime类型,所以显示在网页上的时候会把时间一起显示;

解决方法:@Convert.ToDateTime(日期).ToShortDateString()

------------------------------------------------------------------------------------

更新:之前用的tostring(yyyy--mm--dd)报错  是因为数据是string类型的  需要将它convert.todatetime 后就可以了

猜你喜欢

转载自www.cnblogs.com/zhangyuhao/p/10183852.html