Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format time string in a bound field (grid view)

Status
Not open for further replies.
Joined
Jun 9, 2006
Messages
159
Location
US
Hello,

I have a gridview control with a column like this:


<asp:BoundField DataField="Length" HeaderText="Time" />


The data in the database looks like this:

132
502
321

I would like to to display as such


1:32
5:02
3:21

is there an easy way to do this?



Shawn Molloy
Seattle, WA
 
try adding in your BoundField

DataFormatString="{0:hh:mm}
 
DataFormatString="{0:hh:mm}"

That's assuming a DateTime type.

The easy way to do it is to either change the data type in the database or create a custom type (struct) that presents your data as a string for .NET's data binding syntax.
 
Yeah, the column is not of the type DateTime. I guess I'll perform some sql logic. Thanks.

Shawn Molloy
Seattle, WA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top