DateTime in DataGrid

  • Thread starter Thread starter Vladik
  • Start date Start date
V

Vladik

Hello All

I bound DateTime to DataGrid and I see only date without Time.
How do I suppose to format DataGrid object for time presentation?

Thanks
 
Hi Vladik,

You should check out DataGridTextBoxColumn.Format property.
Or, apply formating in Binding.Format event.
 
Vladik said:
Hello All

I bound DateTime to DataGrid and I see only date without Time.
How do I suppose to format DataGrid object for time presentation?

Thanks

Assuming you've used a TemplateColumn, you can change the datetime format in
the DataBinder.Eval() call:

<ItemTemplate>
<asp:Label id=Lbl_Issued runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Issued", "{0:D}" ) %>'>
</asp:Label>
</ItemTemplate>

This formats a column called "Issued", which is kept in a Label component
referred to as Lbl_Issued. The format specifier is "{0:D}". Look up the
specific format specifier that suits your needs.

Jib
 
Back
Top