Reputation: 5947
I have bound date fields(datetime type column values) to my Grid. In the grid, the column definition is like so My code is:
<asp:Label id="lblFromTimeForTeacher" runat="server" Text='<%# Eval("FromTime", "{0:hh/mm}")%>' Visible="false" Width="99%" />
Right now, the label text is 08-45. Could someone please tell how can I get the label text as 08:45? Thanks in advance.
Upvotes: 2
Views: 1502
Reputation: 6928
Try the following
<asp:Label ID="lblFromTimeForTeacher" runat="server" Text='<%# Eval("FromTime", "{0:hh:mm}")%>' Visible="false" Width="99%" />
if you want in "4:05 PM" format then try the following
<asp:Label ID="lblFromTimeForTeacher" runat="server" Text='<%# Eval("FromTime", "{0:t}")%>' Visible="false" Width="99%" />
For more you can review This Link hope this will help you.
Upvotes: 1
Reputation: 698
Custom DateTime formatting here. In your case just change to Convert.ToDateTime(Eval("FromTime")).ToString("hh:mm")
Upvotes: 3