[RESOLVED] Displaying null date in DataGrid-VBForums
Results 1 to 3 of 3

Thread: [RESOLVED] Displaying null date in DataGrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Posts
    258

    Resolved [RESOLVED] Displaying null date in DataGrid

    Okay, I've got a DataGrid that is displaying data from our database, except when it runs across a NULL datetime value in the database it displays it as "1/1/0001 12:00:00 AM". I'd MUCH rather have it show an empty field in that case... how do I get it to do that?

    This is how I've got the control defined in the DataGrid's XAML.

    Code:
                    <DataGridTemplateColumn Header="Start Date">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding EffDateBegin}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                        <DataGridTemplateColumn.CellEditingTemplate>
                            <DataTemplate>
                                <DatePicker SelectedDate="{Binding EffDateBegin}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellEditingTemplate>
                    </DataGridTemplateColumn>
    I'm using .NET 4.5 in a wpf app...

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: Displaying null date in DataGrid

    Hello,

    This seems to be a WPF question, so I am going to move this thread to the WPF Forum. Please let me know if you have any questions.

    Thanks

    Gary

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Posts
    258

    Re: Displaying null date in DataGrid

    I figured this one out a few minutes ago. The solution was to implement a converter for the field and display an empty string for the null dates.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.