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

RadScheduler postback problem

0 Answers 67 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Eliana
Top achievements
Rank 1
Eliana asked on 31 Jul 2012, 09:55 PM
Hi all:

I have a custom control inside Sitefinity that implements the RadScheduler.  When the page loads, it shows correctly, but when I try to change the selected date, I get this error:

Server Error in '/SiteFinity' Application. DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding

This properties are setted in the code behind.  This is the code I used:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Calendar.ascx.cs" Inherits="SitefinityWebApp.Controls.Calendar" %>
 
<telerik:RadScheduler ID="rsCalendar" runat="server" Skin="Office2007" ReadOnly="True"
                        SelectedView="MonthView" MonthView-VisibleAppointmentsPerDay="15"
                        OverflowBehavior="Expand" CustomAttributeNames="Link"
                        RowHeight="35px">
    <TimelineView UserSelectable="false" />
    <WeekView UserSelectable="false" />
    <DayView UserSelectable="false" />
    <AdvancedForm DateFormat="M/d/yyyy" TimeFormat="h:mm tt" />
    <AppointmentTemplate>   
        <a href='<%#Eval("Link") %>'><%#Eval("Subject")%></a>                   
        <%--<a href='CourseDescription.aspx?cid=<%#Eval("ID") %>'><%#Eval("Subject")%></a>--%>
    </AppointmentTemplate>
    <monthview visibleappointmentsperday="15" AdaptiveRowHeight="True" />
</telerik:RadScheduler>

And the code behind is 

protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
                FillCalendar(DateTime.Now);
            //}
        }
 
        protected void rsCalendar_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
        {
            FillCalendar(rsCalendar.SelectedDate);
        }
        /// <summary>
        /// Fills the calendar with the info
        /// </summary>
        private void FillCalendar(DateTime selDate)
        {
            List<CoursesByDate> cal = dbContext.GetCoursesByDate(selDate).ToList();
 
            rsCalendar.DataSource = cal;
            rsCalendar.DataKeyField = "CourseCode";
            rsCalendar.DataSubjectField = "Course_Description";
            rsCalendar.DataStartField = "Begin_Date";
            rsCalendar.DataEndField = "End_Date";
            rsCalendar.DataBind();
        }

What's wrong?

No answers yet. Maybe you can help?

Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Eliana
Top achievements
Rank 1
Share this question
or