Date and time in Datagrids

D

Dan Aldean

Hello,

I have some fields in the dataset that bear date and time values. When I
bind the datagrid the time part of the fields don't show.
Is it possible to format the datagrid columns so that they show the whole
thing?

Thanks
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What kind of grid are you using? (win or web) ?
How are you binding it?

If a web based you can use a template column and format it as you want :

<asp:TemplateColumn>
<ItemStyle HorizontalAlign="Center" Width="12%"></ItemStyle>
<ItemTemplate>
<span><%# Container.DataItem("INC_UPDATEDATETIME") %></span>
</ItemTemplate>
</asp:TemplateColumn>
 
N

Nicholas Paldino [.NET/C# MVP]

Dan,

What you need to do is get the DataGridTextBoxColumn instance for the
date column, and set the Format property to the format that you want the
date to be shown in.

Hope this helps.
 
D

Dan Aldean

Thanks Ignacio for the reply.
Sorry I wasn't more specific. It is a Windows datagrid.
I use DataSource property to bind to the DataSet
 
D

Dan Aldean

Thanks Nicholas for the answer. Is it valid for Windows Datagrid?

Nicholas Paldino said:
Dan,

What you need to do is get the DataGridTextBoxColumn instance for the
date column, and set the Format property to the format that you want the
date to be shown in.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Dan Aldean said:
Hello,

I have some fields in the dataset that bear date and time values. When I
bind the datagrid the time part of the fields don't show.
Is it possible to format the datagrid columns so that they show the whole
thing?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top