0

我目前正在使用 gridview 并想将我的总分钟字段转换为 hh:mm

这就是我的代码现在的样子,它需要总分钟数并返回 hh.00

 </asp:TemplateField>
                <asp:TemplateField HeaderText="Hours" HeaderStyle-Width="88px">
                    <ItemTemplate>                       
                        <%# (((PendingApprovalListData)Container.DataItem).TotalMinutes / 60.00).ToString("N2")%>
                    </ItemTemplate>
4

2 回答 2

1
you can use this code :

    var Hours = Math.floor(Yourvariable/60);
    var Minutes = Yourvariable%60;

Or you can use this

var span = System.TimeSpan.FromMinutes(Yourvariable);
var hours = ((int)span.TotalHours).ToString();     
var minutes = span.Minutes.ToString();
于 2012-06-26T13:57:04.613 回答
0

客户端示例

<ItemTemplate>
    <asp:Label ID="lblExemptionDate" runat="server" Text='<%#Bind("ExemptDate","{0:dd MMM yyyy HH:mm:ss}")%>'></asp:Label>
</ItemTemplate>
于 2012-06-27T07:04:50.460 回答