This is a migrated thread and some comments may be shown as answers.

DateTime Column in Gridview

5 Answers 272 Views
GridView
This is a migrated thread and some comments may be shown as answers.
CWB
Top achievements
Rank 1
CWB asked on 18 Feb 2009, 09:37 PM
Hello,

I'm new to Telerik controls. Currently checking trial version in order to implement in my Winform project.
I have nullable datetime that I want to update, insert through Gridiview.
If I try to type a value in a column, it wouldn't change in the bounded list (BindingList<T>). If I select in from the datetimepicker, it works OK unless the value is null. I can't update null values. I have Q3 2008 SP2 version.
I checked in the ExamplesCSVS2008 project and saw the same behaviour (Gridview Column Types form grid).
I can replace null value with DateTime.MinValue, but I want to see blank or 00/00/0000 if the bounded value is DateTime.MinValue. In any case it won't solve the manual input issue.
Any ideas how to handle this problem?

Thank you,
Tamar

5 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 20 Feb 2009, 10:50 AM
Hi Tamar,

Thank you for contacting us.

I am not sure if I understand correctly your first question. Could you please describe the desired behavior in more details.

You can format the value of the date time cell when processing the CellFormatting event. Consider the code snippet below:

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement is GridDateTimeCellElement) 
    { 
        GridDateTimeCellElement cell = (GridDateTimeCellElement)e.CellElement; 
        if (cell.Value == DBNull.Value) 
        { 
            cell.Text = "00/00/0000"
        }             
    } 

I am looking forward to your reply.

Regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
CWB
Top achievements
Rank 1
answered on 20 Feb 2009, 02:25 PM
Hello Jack,

Thank you very much for your reply.

I tried the CellFormatting event and I can see now 00/00/0000 date in case the value is null. It's perfect!

However if the value is null and I try to change it through datetimepicker or manually and I exit the cell, I get back 00/00/0000 text and the value in the list remains null.

In case I have some value in a DateTime field, I can change it through datetimepicker and I get new value in the list, but if change it manually and exit the cell, it keeps the previous one, unless during typing in the cell I press space button.

I tried another approach to display and edit date in RadMaskedTextBox and defining masktype as DateTime. But I get an error "Input string was not in a correct format".

I'm about to give up and store date as string and edit them in Grid in regular RadTextBox.
Pleas advise.

Thank you,
Tamar
0
Jack
Telerik team
answered on 23 Feb 2009, 12:30 PM
Hello Tamar,

Currently there is an issue when using the GridViewMaskBoxColumn and DateTime field. We plan to address this issue in our upcoming release.

I could not reproduce the issue with the GridViewDateTimeColumn. Could you please open a support ticket and send us your application. This will help me locate the problem and find a proper solution.

I am looking forward to your reply.

All the best,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
CWB
Top achievements
Rank 1
answered on 02 Mar 2009, 03:51 PM
Hello Jack,

I opened support ticket number 194568.

Looking forward for your reply.
Thank you very much.

Tamar.
0
Jack
Telerik team
answered on 03 Mar 2009, 12:34 PM
Hi Tamar,

You can find the answer to your question in the support ticket. If you have any other questions, please do not hesitate to write us.

All the best,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
CWB
Top achievements
Rank 1
Answers by
Jack
Telerik team
CWB
Top achievements
Rank 1
Share this question
or