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

DatetimeColumn

4 Answers 108 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Raja
Top achievements
Rank 1
Raja asked on 27 Jun 2008, 08:22 PM
How do we set the nulldate and nullvalue for the datetimecolumn in the gridview.

Following code doesn't work. Please suggest.

private void radGVMinMembers_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)

{

if(e.ColumnIndex == 3)

{

    RadDateTimeEditor rdt = new RadDateTimeEditor();

    rdt.NullText =

"";

    rdt.NullValue =

new DateTime(2000, 10, 10);

    radGVMinMembers.CurrentColumn.InitializeEditor(rdt);

 }
}

4 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 30 Jun 2008, 01:54 PM
Hi Raja,

In order to set the NullDate and NullText properties, you should access the RadGridView's ActiveEditor in the CellBeginEdit event handler:
private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)  
{  
    if(e.ColumnIndex == 3)   
    {  
        ((RadDateTimeEditor)this.radGridView1.ActiveEditor).NullText = "";  
        ((RadDateTimeEditor)this.radGridView1.ActiveEditor).NullDate = new DateTime(2000, 10, 10);  
        ((RadDateTimeEditor)this.radGridView1.ActiveEditor).SetToNullValue();  
    }  

I hope this helps. If you have additional questions, feel free to contact me.

Sincerely yours,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Raja
Top achievements
Rank 1
answered on 30 Jun 2008, 03:55 PM
Hi Nikolay,
Thank you for your reply. I see that the solution provided by you did not solve the issue.

I have a date time column in the gridview. I would like to set the text to "" (blankspace) in the cell when the user wants to delete the date(i.e no value in the date time cell). I tried your code it is displaying 1/1/1900 12:00 instead of  "". Please suggest.

Thank you,
Raja.

0
Raja
Top achievements
Rank 1
answered on 30 Jun 2008, 03:55 PM
Hi Nikolay,
Thank you for your reply. I see that the solution provided by you did not solve the issue.

I have a date time column in the gridview. I would like to set the text to "" (blankspace) in the cell when the user wants to delete the date(i.e no value in the date time cell). I tried your code it is displaying 1/1/1900 12:00 instead of  "". Please suggest.

Thank you,
Raja.

0
Nikolay
Telerik team
answered on 03 Jul 2008, 01:13 PM
Hello Raja,

Currently, deleting the date in the RadDateTimeEditor by the user is not supported. You can only can have empty string when you open the RadDateTimeEditor with the code which I provided above. We will address this in one of our next releases.

If you have additional questions, feel free to contact me.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Raja
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Raja
Top achievements
Rank 1
Share this question
or