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

Advanced Form Data Binding

6 Answers 171 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brian Wong
Top achievements
Rank 1
Brian Wong asked on 07 Jul 2010, 02:28 AM
I am trying to pass a value from my database "TrainerID" to my scheduler advanced form.
I have successfully databind the datasource to the scheduler and it displays fine, but when i double click to add a appointment entry i get the following error.

DataBinding: 'Telerik.Web.UI.Appointment' does not contain a property with the name 'TrainerID'


At the bottom note where it has Trainer_ID="<%# Bind('TrainerID') %>, if i put Trainer_ID="10" %> which is a proper trainer ID then ti works fine.

Am i missing something here?

This is the radscheduler aspx:

    <telerik:RadScheduler ID="RadScheduler1" runat="server" Width="100%" Height="" DataKeyField="ScheduleID"
        DataSubjectField="Subject" DataStartField="TimeStart" DataEndField="TimeEnd"
        OnClientFormCreated="schedulerFormCreated" Skin="WebBlue" ShowFooter="False"
        StartInsertingInAdvancedForm="True" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
        OnAppointmentDelete="RadScheduler1_AppointmentDelete" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"
        HoursPanelTimeFormat="h:mmtt">
        <AdvancedForm Modal="true" />
        <TimelineView UserSelectable="false" />
        <TimeSlotContextMenuSettings EnableDefault="true" />
        <AppointmentContextMenuSettings EnableDefault="true" />
        <AdvancedEditTemplate>
            <scheduler:AdvancedForm runat="server" Mode="Edit" ID="AdvancedEditForm1" />
        </AdvancedEditTemplate>
        <AdvancedInsertTemplate>
            <scheduler:AdvancedForm runat="server" Mode="Insert" ID="AdvancedInsertForm1" Trainer_ID="<%# Bind('TrainerID') %>" />
        </AdvancedInsertTemplate>
    </telerik:RadScheduler>


Please help!!

6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 08 Jul 2010, 01:07 PM
Hello Brian,

We have replied in the support ticket about the same issue:

What you need to achieve is the same as in this kb article. Again, please review the code carefully. The selected value of the RadComboBox for Type is set from code-behind of the AdvancedForm user control:
'Type, Resource     
    <Bindable(BindableSupport.Yes, BindingDirection.TwoWay)> _  
    Public Property Type() As String
        Get
            Return TypeComboBox.SelectedValue.ToString()  
        End Get
      
        Set(ByVal value As String)  
            TypeComboBox.SelectedValue = value  
        End Set
    End Property

The value comes correctly because of the following binding expression:
<AdvancedEditTemplate
            <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit"
                Subject='<%# Bind("Subject") %>' 
                Description='<%# Bind("Description") %>'  
                Start='<%# Bind("Start") %>' 
                End='<%# Bind("End") %>' 
                RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' 
                AppointmentColor='<%# Bind("AppointmentColor") %>'  
                Type='<%# Bind("Type") %>'  
                Resource='<%# Bind("Resource") %>'  
                UserID='<%# Bind("User") %>' 
                RoomID='<%# Bind("Room") %>' /> 
        </AdvancedEditTemplate
        <AdvancedInsertTemplate
            <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert"
                Subject='<%# Bind("Subject") %>' 
                Start='<%# Bind("Start") %>' 
                End='<%# Bind("End") %>' 
                Description='<%# Bind("Description") %>' 
                RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' 
                AppointmentColor='<%# Bind("AppointmentColor") %>'   
                Type='<%# Bind("Type") %>'  
                Resource='<%# Bind("Resource") %>'  
                UserID='<%# Bind("User") %>' 
                RoomID='<%# Bind("Room") %>' /> 
        </AdvancedInsertTemplate

The same mechanism is used to save the value. There is no extra code you need to achieve this functionality. That's what I meant by that there is no need to handle AppointmentInsert or AppointmentUpdate.


Best wishes,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Brian Wong
Top achievements
Rank 1
answered on 08 Jul 2010, 01:24 PM
I have done exactly that.
See my code below in advancedform.ascx.vb code behind:

        <Bindable(BindableSupport.Yes, BindingDirection.TwoWay)> _
        Public Property TrainerID() As Integer
            Get
                Return Me.intTrainerID
            End Get

            Set(ByVal value As Integer)
                Me.intTrainerID = value
            End Set
        End Property

I have databind a datasource with TrainerID but when i go to insert an appointment, TrainerID is still 0
0
Peter
Telerik team
answered on 08 Jul 2010, 01:55 PM

You also need to set CustomAttributeNames="TrainerID" for RadScheduler.


Kind regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Brian Wong
Top achievements
Rank 1
answered on 08 Jul 2010, 02:01 PM
I have also done this (after posting my code). This is something i have added since initially posting to this forum.
0
Brian Wong
Top achievements
Rank 1
answered on 12 Jul 2010, 03:27 AM
Just so that I'm hopefully a bit clearer, I am actually trying to get the advanced form to pick up a value that is bound to the scheduler so that it can populate comboboxes etc inside the advanced form, for the user to select values, based on the info provided by the scheduler.

With that bind(..etc method, it is consistently passing in 0 to the advanced form. But i know for sure that value bound to the scheduler has a value.
0
Peter
Telerik team
answered on 13 Jul 2010, 02:53 PM
Hi Brian,

The sample from the kb article I referred  you to works as expected. I am not sure what is different in your case. Can you modify our demo so that the problem occurs and explain what changes you have made?


Regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Brian Wong
Top achievements
Rank 1
Answers by
Peter
Telerik team
Brian Wong
Top achievements
Rank 1
Share this question
or