How to set time format when databinding in repeater

Viewed 132
<asp:Repeater ID="rjob" runat="server">
    <ItemTemplate>
      <div class="product-category">
           <span style="width: 150px;">Start Time:</span>
              <ul>
                 <li><%# Eval("WS_START","{%p}")%></li>
              </ul>
      </div>
      <div class="product-category">
           <span style="width: 150px;">End Time:</span>
           <ul>
               <li><%# Eval("WS_END","{0:HH:mm:ss}") %></li>
           </ul>
      </div>
    </ItemTemplate>
</asp:Repeater>

Hi I am having some issues, trying to display the output as: 9:00 AM, The datatype is TIME. I have tried a lot of format but none is working.

1 Answers
<asp:Repeater ID="rjob" runat="server">
    <ItemTemplate>
      <div class="product-category">
           <span style="width: 150px;">Start Time:</span>
              <ul>
<li><%# (DateTime.Parse(Eval("WS_START").ToString()).ToShortTimeString()) %></li>

              </ul>
      </div>
      <div class="product-category">
           <span style="width: 150px;">End Time:</span>
           <ul>
    <li><%# (DateTime.Parse(Eval("WS_END").ToString()).ToShortTimeString()) %></li>
           </ul>
      </div>
    </ItemTemplate>
</asp:Repeater>

This will work.

Related