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

AppointmentDataBound fires twice when changing views

4 Answers 125 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Ross Dunham
Top achievements
Rank 1
Ross Dunham asked on 14 Nov 2011, 05:06 AM
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.

4 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 16 Nov 2011, 05:05 PM
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
0
Ross Dunham
Top achievements
Rank 1
answered on 17 Nov 2011, 03:43 AM
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
0
Alexander
Top achievements
Rank 1
answered on 21 Nov 2011, 12:26 PM
is there any solution?

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

greets

Alex
0
Ivana
Telerik team
answered on 22 Nov 2011, 02:16 PM
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
Tags
Scheduler
Asked by
Ross Dunham
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Ross Dunham
Top achievements
Rank 1
Alexander
Top achievements
Rank 1
Share this question
or