简体   繁体   中英

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? For example I type 15 00 in Detailsview and in saves as 15:00 in my GridView_Table(sql).

If you want a custom date format in your gridview you use the DataFormatString attribute on your BoundField something like

<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

You can use HH mm instead of your want 0 to be 00 for both minutes and hours.

And btw someone inviting you to use something else when you ask a question about asp.net is a bit rude

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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