New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

How to display all RadScheduler appointments in GridView

HOW-TO

Display all RadScheduler appointments in GridView

SOLUTION

Here is the code solution:

C#
protected void RadScheduler1_DataBound(object sender, EventArgs e)  
    {  
        //Create a dynamic table to store the appointments' information:     
        DataTable table1 = new DataTable();  
        table1.Columns.Add("Subject");  
        table1.Columns.Add("Start");  
        table1.Columns.Add("End");  

        foreach (Appointment a in RadScheduler1.Appointments)  
        {  
            //Occurrences of a recurrence master are not generated untill they      
            //are within RadScheduler's visible range. This mandates the occurrences     
            //information to be extracted from the Master's recurrence rule as follows:     
            if (a.RecurrenceState == RecurrenceState.Master)  
            {  
                RecurrenceRule parsedRule;  
                RecurrenceRule.TryParse(a.RecurrenceRule.ToString(), out parsedRule);  
 
                //If a recurring appointment does not have specified end time it will have     
                //endless occurrences. In this case you can explicitly put a restriction:     
                //parsedRule.SetEffectiveRange(DateTime.Now.AddYears(-1), DateTime.Now.AddYears(1));     
                foreach (DateTime occurrence in parsedRule.Occurrences)  
                {  
                    table1.Rows.Add(new string[] { a.Subject.ToString(), occurrence.ToString(), occurrence.Add(a.Duration).ToString() });  
                }  
            }  
            else //Get the rest of the appointments     
 
                //If the SelectedDate of RadScheduler is set so that the visible range encompasses occurences of      
                //a recurring appointement, these occurences will be generated now so they will be added once again     
                //to the DataTable. To prevent this, we use the following check:     
                if (a.RecurrenceState != RecurrenceState.Occurrence)  
                {  
                    table1.Rows.Add(new string[] { a.Subject.ToString(), a.Start.ToString(), a.End.ToString() });  
                }  
        }  

        GridView1.DataSource = table1;  
        GridView1.DataBind();     
     } 
In this article
HOW-TOSOLUTION
Not finding the help you need?
Contact Support