中继器数据绑定时如何设置时间格式

How to set time format when databinding in repeater

<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>

嗨,我遇到了一些问题,试图将输出显示为:9:00 AM,数据类型为 TIME。我尝试了很多格式,但 none 有效。

<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>

这会起作用。