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

MinDate on GridDateTimeColumn

3 Answers 162 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Johan Andersson
Top achievements
Rank 1
Johan Andersson asked on 08 Jun 2009, 02:27 PM
Hi,
I have tried to find the answer in the forum without success, of the issue I'm having.
I'm setting a MinDate programmatically in the ItemBound:

 

protected void RadGridiPur_ItemDataBound(object sender, GridItemEventArgs e)

 

{    
    

if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)

 

    {

 

        GridEditableItem edititem = e.Item as GridEditableItem;

 

 

        RadDatePicker dtpkrSend = (RadDatePicker)edititem["SendDate"].Controls[0];

 

 

        DateTime dtTmp = DateTime.Today;

 

        dtpkrSend.MinDate = dtTmp.AddDays(1);
        ...

But I can still choose the days in the Calendar before this date, compared to when I'm setting the date in the designermode:
... MinDate="08-Jun-2009 00:00:00"></telerik:GridDateTimeColumn>

 

 

 

Can I in some way get the same behaviour as when setting the date in designermode, as programmetically? My intention is to force our users to set the date tomorrow and forth.
Thanx for feedback!
Cheers
Johan

3 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 08 Jun 2009, 03:31 PM
Did u try this

  dtpkrSend.MinDate = datetime.now..AddDays(1);

 instead of 

   dtpkrSend.MinDate = dtTmp.AddDays(1);

Thnx 

John
0
Accepted
Princy
Top achievements
Rank 2
answered on 09 Jun 2009, 08:09 AM
Hi Johan Andersson,

Try the following code and see whether it is working as expected.

.aspx
 
  . . .     
<telerik:GridDateTimeColumn PickerType="DatePicker" UniqueName="SendDate" HeaderText="SendDate" DataField="SendDate">     
</telerik:GridDateTimeColumn>    
  . . .   

.cs
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
{  
    if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)  
    {  
        GridEditableItem edititem = e.Item as GridEditableItem;  
        RadDatePicker dtpkrSend = (RadDatePicker)edititem["SendDate"].Controls[0];  
        DateTime dtTmp = DateTime.Today;  
        dtpkrSend.SharedCalendar.RangeMinDate = dtTmp.AddDays(1);  
    }  

-Princy
0
Johan Andersson
Top achievements
Rank 1
answered on 09 Jun 2009, 09:56 AM
Thanks Princy!
That was the behaviour I was looking for when setting the date to dtpkrSend.SharedCalendar.RangeMinDate.
Now the users cannot select any day before the date I have specified.
Thanks a lot!
br
johan
Tags
Calendar
Asked by
Johan Andersson
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Johan Andersson
Top achievements
Rank 1
Share this question
or