我数据库里有个字段是smallDateTime类型,但是在GridView中显示时现实了长时间格式:2007-1-1 0:00:00我想在GridView中现实短的时间格式,我看了数据库里的数据也是短的时间格式,为什么现实出来就变成长的了呢?我通过后台FormatDateTime方法,
<asp:TemplateField HeaderText="date">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# FormateDateTime((Conver.ToDateTime(Eval("date"))) %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>后台程序:
FormatDateTime(DateTime dateTime)
{
....
}
但是总是提示我无法转换请问如何能完成我想要的结果,万分感谢!
<asp:TemplateField HeaderText="date">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# FormateDateTime((Conver.ToDateTime(Eval("date"))) %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>后台程序:
FormatDateTime(DateTime dateTime)
{
....
}
但是总是提示我无法转换请问如何能完成我想要的结果,万分感谢!
解决方案 »
- 求一个过滤特殊符号(用语防止SQL注入问题)的通用方法供其他页面调用?
- asp.net中怎样在前台用js为html标签的文本框赋当前时间和当前时间的前三天的时间?
- gridview 布局问题
- Asp.net MVC模式注册中Ajax实现。
- 一个关于删除接点的问题
- 论坛上青岛的朋友近来看看,顶者有份
- 大家介绍一下Sql2005的使用体验
- 隐藏列后,返回的值(隐藏列)变为NULL,为什么???
- 关于服务器文件下载时,保存的文件类型问题
- 页面间数据传递问题请教
- droplist.Items.Insert(0, new ListItem("",""));
- gridview 中某个列绑定的是datetime字段,要求显示年月,不显示日和时间
{
return dateTime.ToShortDateString();
}
HtmlEncode=false DataFormatString="{0:yyyy年MM月dd日}" 这里就能改变格式
你肯定是把段类型又转成长的了
<asp:BoundField DataField="processDate" HeaderText="申请日期" DataFormatString="{0:d}" HtmlEncode="False" />自己试试看!!!