格式字符串的DateTime重新$ P $在GridView的数据psentation [英] Format DateTime string representation in GridView dataset
问题描述
只是在寻找一些策略来修改典型
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屋!