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

Format datetime picker inside the rad grid

1 Answer 251 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prassin
Top achievements
Rank 1
Prassin asked on 09 Oct 2012, 10:11 AM
Hi All,

I have a RadDateTimePicker inside my RadGrid. i wish to format the Datetime picker like "dd mon yyyy hh:mm:ss:mmm".
my sql date format like "SELECT convert(varchar, getdate(), 113)"

how can i format my datetime picker like my sql date time format.

Please help.

Thanks 

Prassin

1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 09 Oct 2012, 11:20 AM
Hello,

try with Below code snippet.

With template column

<telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" Width="200px">
                               <DateInput DateFormat="dd MMM yyyy hh:mm:ss:mmm">
                               </DateInput>
                           </telerik:RadDateTimePicker>
                       </ItemTemplate>
                       <EditItemTemplate>
                           <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" Width="200px">
                               <DateInput DateFormat="dd MMM yyyy hh:mm:ss:mmm">
                               </DateInput>
                           </telerik:RadDateTimePicker>
                       </EditItemTemplate>
                   </telerik:GridTemplateColumn>

With DateTime Column
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {          
                GridEditableItem editedItem = e.Item as GridEditableItem;
                (editedItem["Customedate"].Controls[0] as RadDateTimePicker).DateInput.DateFormat = "dd MMM yyyy hh:mm:ss:mmm";
             
        }
    }
<telerik:GridDateTimeColumn DataField="Customedate" UniqueName="Customedate" PickerType="DateTimePicker">
                   </telerik:GridDateTimeColumn>

Normal Mode
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" Width="200px">
            <DateInput DateFormat="dd MMM yyyy hh:mm:ss:mmm">
            </DateInput>
        </telerik:RadDateTimePicker>


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Prassin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or