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

Date columns in Gridview

1 Answer 49 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sandi Markon
Top achievements
Rank 1
Sandi Markon asked on 26 Oct 2009, 12:20 PM
Hello.

I have 2 date columns in GridView. When inserting a new row, when I click first date column, today's date appears in calendar and when I click second one, date which appears in calendar is 1.1.1900. What do I have to set that when inserting new row, default date when I open calendar would be today's date.

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 29 Oct 2009, 02:53 PM
Hi Sandi Markon,

Thank you for writing.

I am unable to reproduce the described behavior. The date time editor always shows today the default value. However you can try to explicitly set it in CellBeginEdit event:

void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    RadDateTimeEditor editor = this.radGridView1.ActiveEditor as RadDateTimeEditor;
    if (editor != null)
    {
        ((RadDateTimeEditorElement)editor.EditorElement).Value = DateTime.Today;
    }
}

Please, keep in mind that this code is tested with Q2 2009. Let me know if you are using an older version or this does not help.

Regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Sandi Markon
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or