I've got a nullable column in SQL Server 2008 that I use to store a time. When I use LINQ to SQL and pull data back it comes back as TimeSpan?. When I bind that to a GridView and try to format it using DataFormatString="{0:t}" it still shows the seconds. Any thoughts?
+1
A:
Make sure you also disable Html encoding for your format to work.
HtmlEncode="false"
Zachary
2010-06-07 20:54:31
Good suggestion. It looks like this has something to do with how .NET uses TimeSpans for Times instead of DateTimes.
Nissan Fan
2010-06-07 20:57:43
+1
A:
The problem is that TimeSpan
doesn't implement IFormatable. So you can't directly format TimeSpans.
Keltex
2010-06-07 21:05:20