简体   繁体   English

在详细信息视图中插入日期时间并将“空格”替换为“:”

[英]insert datetime and replace “space” to “:” in detailsview

Is it possible to insert the datetime like "15 00" instead of "15:00" inside my detailsview? 是否可以在详细信息视图中插入日期时间,例如“ 15 00”而不是“ 15:00”? For example I type 15 00 in Detailsview and in saves as 15:00 in my GridView_Table(sql). 例如,我在Detailsview中键入15 00,然后在GridView_Table(sql)中另存为15:00。

If you want a custom date format in your gridview you use the DataFormatString attribute on your BoundField something like 如果要在gridview中使用自定义日期格式,请在BoundField上使用DataFormatString属性,例如

<asp:BoundField DataField="ModifiedDate" HeaderText="ModifiedDate" SortExpression="ModifiedDate" DataFormatString="{0:H m}" />

H in the format string: The hour, using a 24-hour clock from 0 to 23. m in the format string: The minute, from 0 through 59 格式字符串中的H:小时,使用从0到23的24小时制。m格式字符串中的m:分钟,从0到59

You can use HH mm instead of your want 0 to be 00 for both minutes and hours. 您可以使用HH mm来代替分钟和小时的0均为00。

And btw someone inviting you to use something else when you ask a question about asp.net is a bit rude 顺便说一句,当有人问您有关asp.net的问题时邀请您使用其他东西是有点粗鲁的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM