Keith Adler
Keith Adler

Reputation: 21178

SQL Server 2008 Time column messing up GridView DataFormatString

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?

Upvotes: 0

Views: 497

Answers (2)

Keltex
Keltex

Reputation: 26426

The problem is that TimeSpan doesn't implement IFormatable. So you can't directly format TimeSpans.

Upvotes: 1

Zachary
Zachary

Reputation: 6532

Make sure you also disable Html encoding for your format to work.

HtmlEncode="false"

Upvotes: 1

Related Questions