1
Answer

Date time Formate in Datagrid ItemTemplate

Mohit Sharma

Mohit Sharma

15y
6.9k
1
Hi
can any one help me? I have a datetime field in a SQL Server 5.0 database that is bound to a DataGrid Item template.
I really only want to display the time portion of the field i.e. hh:mm:ss. I need to specify a custom format specifier
but have not been able to find any specific examples that fit my circumstance.

<asp:TemplateField HeaderText="Created Date">
    <HeaderStyle Width="10%" />
        <ItemStyle ForeColor="#ffffcc" HorizontalAlign="center" />
            <ItemTemplate>
                <%# DataBinder.Eval(Container.DataItem, "Time").ToString("hh:mm:ss") %>
            </ItemTemplate>
        </asp:TemplateField>
Answers (1)