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

set default DateTime in RadDateTimePicker

5 Answers 1561 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Hadoop
Top achievements
Rank 1
Hadoop asked on 17 Jun 2015, 12:27 AM

Language : : C#, ASP.NET

How can I set default DateTime value in RadDateTimePicker. Default value should be one day greater than the current date with time as "12:00 AM". How can I do this?

5 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 19 Jun 2015, 12:07 PM
Hi,

In order to implement the behavior you can handle the Load event of the RadDateTimePicker and set the appropriate date.


<telerik:RadDateTimePicker runat="server" ID="RadDateTimePicer1" OnLoad="RadDateTimePicer1_Load"></telerik:RadDateTimePicker>


protected void RadDateTimePicer1_Load(object sender, EventArgs e)
{
    (sender as RadDateTimePicker).SelectedDate = DateTime.Today.AddDays(1);
}



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Adam
Top achievements
Rank 1
answered on 22 Dec 2017, 10:15 AM

How about if the RadDateTimePicker is inserted in a <GridDateTimeColumn> e.g.

<telerik:GridDateTimeColumn DataField="StartDate" PickerType="DateTimePicker" SortExpression="StartDate" UniqueName="StartDate" />

 

How can we set a default datetime for the picker then? I just want to default the picker to NOW()

0
Eyup
Telerik team
answered on 26 Dec 2017, 11:40 AM
Hello Adam,

If you mean the inserting form, then you can directly use the following property to achieve that:
<telerik:GridDateTimeColumn ... DefaultInsertValue="5/5/2015">

Alternatively, you can access the generated controls manually:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode

Analogously, for filtering you can also use ItemDataBound event handler:
https://www.telerik.com/support/kb/aspnet-ajax/grid/details/reduce-cell-width-of-radgrid-range-filtering

However, if you want to apply initial filtering to grid columns, you should use the FireCommandEvent method:
https://www.telerik.com/forums/setting-a-filter-in-the-index-changed-event-of-a-drop-down-combo-not-filtering-the-grid#_QnXxSMs5Uq9rddb2JWcWA

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Hannah
Top achievements
Rank 1
answered on 25 Apr 2018, 05:22 PM
When I tried implementing the load event of the  I got a null reference exception - what am I missing?
0
Eyup
Telerik team
answered on 01 May 2018, 08:46 AM
Hello Hannah,

Generally, the Controls[0] approach should return the generated combo or dropdownlist control:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode

Please note that if you are using Batch editing mode, things a little bit different:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-batch-edit-mode

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
DateTimePicker
Asked by
Hadoop
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Adam
Top achievements
Rank 1
Eyup
Telerik team
Hannah
Top achievements
Rank 1
Share this question
or