Need some help with DataFormatString in GridView. I have a Double value that needs to be shown as TimeSpan. I have tried DataFormatString=”{0:HH:mm:ss}”. This did not work.
Tested it a bit in C# and there I would do:
TimeSpan.FromHours(16.7358217592592).ToString()
This gives me.
"16:44:08.9580000"
Which is what i am after. But how to get it in ASP.Net is the big question.
Any Suggestions?
I have a simple GridView that looks like this.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="sOprTime" HeaderText="Sum OprTime" ReadOnly="True" SortExpression="sOprTime" />
<asp:BoundField DataField="sWorkTime" HeaderText="Sum WorkTime" ReadOnly="True" SortExpression="sWorkTime" />
<asp:BoundField DataField="sFaultTime" HeaderText="Sum FaultTime" ReadOnly="True" SortExpression="sFaultTime" />
</Columns>
<EmptyDataTemplate>
No data is present.
</EmptyDataTemplate>
The SQL query looks like this:
sqlString1 = string.Format(@"SELECT SUM(CONVERT (Float, OprTime)) AS sOprTime, SUM(CONVERT (Float, WorkTime)) AS sWorkTime, SUM(CONVERT (Float, OprTime)) - SUM(CONVERT (Float, WorkTime)) AS sFaultTime FROM tblNovikLogg WHERE (Date_Time > '{0:yyyy/MM/dd H:mm:ss}' And Date_Time < '{1:yyyy/MM/dd H:mm:ss}')", selectedDate, selectedDate.AddDays(1));
You could do that in
RowDataBound: