I have a label in the grid whose value is populated from a dropdown in a popup window(The dropdown has time values in hours - 00 to 23). I have bound the label in the grid like so.
<asp:Label ID="lblFromTime" runat="server" Text='<%# Eval("FromTime", "{0:hh/mm}")%>'></asp:Label>
The problem is when I select 13 from the dropdown(anything greater than 12 for that matter), it is populating as 01-00 rather than 13-00 .
How do I display the value as 13-00 ?
EDIT:
When I change the label like
<asp:Label ID="lblFromTime" runat="server" Text='<%# Eval("FromTime", "{0:HH/MM}")%>'></asp:Label>
and select 13 from my dropdown, it displays the text as 13-04 .
You need to change the format to:
"{0:HH/mm}"
So for example:
<asp:Label ID="lblFromTime" runat="server" Text='<%# Eval("FromTime", "{0:HH/mm}")%>'></asp:Label>
Capital HH
is the key.
This is a good TimeFormatting reference
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.