RadScheduler to show All Day Event

4.8k Views Asked by At

Hey, here is a stupid question for you. What do you have to do to get an appointment to displayed as an all day event in Telerik's RadScheduler? How do you tell the RadScheduler that this specific record is an all day event (something to do with start and end dates)?

1

There are 1 best solutions below

0
On

One way to do it is as follows:

In your aspx file add the following attribute to the RadScheduler tag

<Telerik:RadScheduler runat="server" id="rsCalendar" ShowAllDay="true"
DataStartField="StartDate" DataFndField="EndDate">
</Telerik:RadScheduler>

I have not entered all the attributes that are required. You can fill those in.

Then in your code behind file have a difference of 24 hours in your StartDate and EndDate. Note that since start date and end date are datetime fields you can have time in it and hence have a difference of 24 hours in them. This will automatically appear as allday event in the calendar.

I created a new DataTable and provided that as a Data Source to the RadScheduler.



    DataTable dt = new DataTable();

    //The columns added are similar to the attributes in the RadScheduler control
    dt.Columns.Add("StartDate", GetType(DateTime));
    dt.Columns.Add("EndDate", GetType(DateTime));

    //Assigning the StartDate And EndDate some values for each row
    //that I want in this table
    DataRow dRow = dt.NewRow();
    dRow("StartDate") = sDate;  //Arbitrary variable containing the date
    dRow("EndDate") = sDate.AddHours(24);
    dt.Rows.Add(dRow);

    //Now bind this data table to the RadScheduler
    rsCalendar.DataSource = dt.DefaultView;
    rsCalendar.Databind();

That is all there is that needs to be done. Also for each appointment or entry in the calendar a new row has to be created for the DataTable.

There are other ways to do this and this is one of them.