格式字符串的DateTime重新$ P $在GridView的数据psentation [英] Format DateTime string representation in GridView dataset

查看:130
本文介绍了格式字符串的DateTime重新$ P $在GridView的数据psentation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是在寻找一些策略来修改典型

Just looking for some strategies to modify the typical

MM / DD / YY 00:00:00简单结果
在绑定到GridView的数据集返回日期时间项目的MM / DD / YY

mm/dd/yy 00:00:00 to simply
mm/dd/yy of a datetime item being returned in a dataset that is bound to the gridview

感谢

该项目是一个数据集内,我简单地做以下

the item is within a dataset and I am simply doing the following

gridview.DataSource = GetDataSet();
gridview.DataBind();

所以,我没有与此刻的数据集一吨的互动。我可以通过它的蛮力迭代,并做一些像

So I don't have a ton of interaction with the dataset at the moment. I could brute force iterate through it and do something like

foreach(Table)
   foreach(Row)
      grab date Col, format and concat to look as desired

但是这是非常乱,不知道是否有一个更优雅的解决方案。

but this is very messy and was wondering if there is a more elegant solution.

推荐答案

只要指定GridView中DataFormatString

Just specify the DataFormatString in the GridView

<asp:BoundField HeaderText="Date" DataField="MyDate" 
     DataFormatString="{0:MM/dd/yy}">

这篇关于格式字符串的DateTime重新$ P $在GridView的数据psentation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆