Format GridView Time

0

Good morning, I have a field in the grid, which is populated from a SQL Time field (7).

It appears like this on the grid: 15: 10: 51.1000000

But I would like it to look this way: 15:10:51, and in every way I try, it's not right, I tried this way: DataFormatString="{0: hh: mm}", like this: DataFormatString="{ 0: t ""

Either it gives the string error or simply it does not convert to the right format. I would like to know the right way to convert the column to the grid. Thanks.

No way I try to work, do you have any way to configure the GridView time?

    
asked by anonymous 12.04.2017 / 13:18

1 answer

2

Use the so:

DataFormatString="{0:HH:mm}"

The HH must be uppercase

Example:

<asp:BoundField DataField="hora" HeaderText="Hora" SortExpression="Hora" DataFormatString="{0:HH:mm}" ShowHeader="True" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"/>
    
12.04.2017 / 13:24