AppointmentDataBound fires twice when changing views

5 posts, 0 answers
  1. Ross Dunham
    Ross Dunham avatar
    11 posts
    Member since:
    Mar 2006

    Posted 13 Nov 2011 Link to this post

    I have 4 appointments that I am loading from a custom datasource(datatable) into the RadScheduler control.

    When the page first loads the AppointmentDataBound event occurs 4 times. (once for each appointment)

    When I change VIEWS (from MONTH to WEEK or vice versa) that the AppointmentDataBound event occurs 8 times.
    Double.

    Am I doing something wrong?  Is this by design?
    Is there anything that I can do to stop it from doing this?

    Thanks in advance for any guidance.
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 16 Nov 2011 Link to this post

    Hello Ross,

    I could not produce the behavior in question, locally. I've tested the scenario when appointments are added  to the RadScheduler on Page_Load event, and when it is bound to a data source (Xml and SqlDataSource). In both cases everything was working as expected.

    Please paste some of your server-side code here, or send us a support ticket with a runnable sample page reproducing the issue.

    Kind regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Ross Dunham
    Ross Dunham avatar
    11 posts
    Member since:
    Mar 2006

    Posted 16 Nov 2011 Link to this post

    Hi Ivana,
    Thank you very much for your response.  I suspected that the issue is on my end.
    Lets start with me putting up my my code and if we still can't figure it out, then I will submit a support ticket with a full solution.

    Just to make sure I was clear, the databind happens the correct number of times on FormLoad.
    It's only when I click WEEK or MONTH, or back and forth between views that the databind happens double.

    here is my RadScheduler control
    <telerik:RadScheduler ID="radSchedulerHospital" runat="server" DataEndField="EndTime"
                            DataKeyField="ApptID" DataStartField="StartTime"
                            DataSubjectField="Subject" EnableDescriptionField="False" Height="" OverflowBehavior="Expand"
                            SelectedView="MonthView" StartInsertingInAdvancedForm="False"
                            AllowInsert="False" AllowDelete="False" AllowEdit="False"
                            CustomAttributeNames="LabID, LabID ,ApptTypeID, ApptTypeID" Skin="Office2007" ReadOnly="True" MonthView-VisibleAppointmentsPerDay="8">
                        <ExportSettings OpenInNewWindow="True">
                        </ExportSettings>
                        <TimelineView UserSelectable="False" />
                        <Reminders Enabled="False" />
                        <TimeSlotContextMenuSettings EnableDefault="False" />
                    </telerik:RadScheduler>

    Here is my Code Behind File
    Imports System.Data
    Imports Telerik.Web.UI
    Imports RepSched.rsUser
    Imports RepSched.rsAppt
     
    Partial Class app_hospital_Default
        Inherits System.Web.UI.Page
     
        Private Const ApptKey As String = "hosp.appts"
        Private iPrevLabID As Integer = 0
        Private iCurrentColorIndex As Integer = 1
        Private iLabColor(8) As String
     
        Private ReadOnly Property Appointments() As DataTable
            Get
                Dim dtAppts As DataTable = TryCast(Session(ApptKey), DataTable)
                If IsNothing(dtAppts) Then
                    dtAppts = LoadHospitalAppts(CInt(Session("HospitalID")))
                    Session(ApptKey) = dtAppts
                End If
                Return dtAppts
            End Get
        End Property
     
        Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            Session.Remove("NewLab")
            CheckRole(USERROLE_HOSPITAL, CInt(Session("Role")))
     
            'We are back to the hospital view, remove reference to LabID
            Session.Remove("LabID")
     
            If Not IsPostBack Then
                Dim db As New RepSchedulerDataContext
                lblHospitalName.Text = Session("HospitalName")
                Session.Remove(ApptKey)
            End If
     
            LoadColors()
            radSchedulerHospital.DataSource = Appointments
     
        End Sub
     
        Protected Sub radSchedulerHospital_AppointmentDataBound(ByVal sender As Object, ByVal e As SchedulerEventArgs) Handles radSchedulerHospital.AppointmentDataBound
            Dim iCurrentLabID As Integer = CInt(e.Appointment.Attributes("LabID"))
     
            'initialize first time running
            If iPrevLabID = 0 Then
                iPrevLabID = iCurrentLabID
            End If
     
            '  Increment color when we get to the next labs appointments
            If iCurrentLabID <> iPrevLabID Then
                iCurrentColorIndex += 1
                iPrevLabID = iCurrentLabID
            End If
     
            e.Appointment.CssClass = iLabColor(iCurrentColorIndex)
        End Sub
     
        Protected Sub LoadColors()
            iLabColor(1) = "rsCategoryDarkRed"
            iLabColor(2) = "rsCategoryDarkGreen"
            iLabColor(3) = "rsCategoryOrange"
            iLabColor(4) = "rsCategoryBlue"
            iLabColor(5) = "rsCategoryYellow"
            iLabColor(6) = "rsCategoryRed"
            iLabColor(7) = "rsCategoryGreen"
            iLabColor(8) = "rsCategoryDarkBlue"
        End Sub
     
        Protected Sub ibtnPdf_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ibtnPdf.Click
            CreateCalendarPDF(radSchedulerHospital)
        End Sub
    End Class

    Thanks in advance!!
    Ross
  4. Alexander
    Alexander avatar
    1 posts
    Member since:
    Nov 2011

    Posted 21 Nov 2011 Link to this post

    is there any solution?

    the same problem occurs in my VS2008 project
    (Code-Behind: C#)

    greets

    Alex
  5. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 22 Nov 2011 Link to this post

    Hi Ross Dunham,

    The linked video below, shows how the OnAppointmentDataBound event behaves when the Scheduler is bound to a XML data provider, when I test it locally: OnAppointmentDataBound server-side call.

    Please open a support ticket and send us a working sample project with the issues isolated in it, so we would be able to troubleshoot this problem locally.

    All the best,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top