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

RadDatePicker Problem

1 Answer 29 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kyle Jones
Top achievements
Rank 1
Kyle Jones asked on 07 Aug 2009, 08:15 PM
Hey,

I am having a problem with a RadDatePicker.  My picker is sitting inside a GridTemplateColumn under the EditItem section.  I am wanting to set the SelectedDate and the MaxDateRange from the codebehind but I cannot figure out how to access the control.  Can you please help me out??


Thanks,

Kyle

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 10 Aug 2009, 06:07 AM
Hello Kyle,

Try the following code snippet in order to set the SelectedDate, MinDate and MaxDate properties of RadDatePicker (placed in EditItemTemplate) from code behind.

ASPX:
 
<telerik:GridTemplateColumn> 
    <EditItemTemplate> 
        <telerik:RadDatePicker ID="RadDatePicker1" runat="server">  
        </telerik:RadDatePicker>                              
    </EditItemTemplate>                          
</telerik:GridTemplateColumn> 

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
{  
    if (e.Item is GridEditFormItem && e.Item.IsInEditMode)  
    {  
        GridEditFormItem item = (GridEditFormItem)e.Item;  
        RadDatePicker DatePicker = (RadDatePicker)item.FindControl("RadDatePicker1");  
        DatePicker.SelectedDate = DateTime.Now.Date;  
        DatePicker.MinDate = Convert.ToDateTime("07/07/2009");  
        DatePicker.MaxDate = Convert.ToDateTime("09/09/2009");  
    }  

Thanks,
Princy.
Tags
Calendar
Asked by
Kyle Jones
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or