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

Problems with showing Resource data in Appointment template

5 Answers 218 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Wim Tra Kranen
Top achievements
Rank 1
Wim Tra Kranen asked on 28 Aug 2009, 08:10 AM
I want to display some data from a resource datasource but i get the error:
process is not a valid item of an appointment

here is my definition of radscheduler:

            <telerik:RadScheduler ID="RadScheduler1" runat="server" AllowDelete="True" AllowEdit="False" 
                AllowInsert="True" DataEndField="End" DataKeyField="ID" DataSourceID="dsSchedules" 
                DataStartField="Start" DataSubjectField="Subject" FirstDayOfWeek="Sunday" LastDayOfWeek="Saturday" 
                OverflowBehavior="Expand" SelectedView="WeekView" Culture="Dutch (Netherlands)" 
                DataRecurrenceField="strRecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID" 
                MinutesPerRow="15" Skin="Web20" StartInsertingInAdvancedForm="True" EnableCustomAttributeEditing="True" 
                OnAppointmentCreated="RadScheduler1_AppointmentCreated" WeekColumnHeaderDateFormat="dddd, d" 
                WeekHeaderDateFormat="D" WorkDayEndTime="21:00:00"   
                WorkDayStartTime="07:30:00" ondatabound="RadScheduler1_DataBound"   
                CustomAttributeNames="Enabled,Remarks">  
                <ResourceTypes> 
                    <telerik:ResourceType DataSourceID="dsWorkFlows" KeyField="Key"   
                        Name="process" TextField="Value"  ForeignKeyField="workflowTypeID"/>  
                </ResourceTypes> 
                 
                <AppointmentTemplate> 
                    <table style="width: 100%;">  
                        <tr> 
                            <td class="ScheduledTaskHeader" style="width: 16px;">  
                                <img runat="server" id="icon" alt="Icon" src='<%# GetImage(Eval("Start").ToString()) %>' style="float: left;" /> 
                            </td> 
                            <td class="ScheduledTaskHeader">  
                                <%# Eval("Subject") %> 
                            </td> 
                        </tr> 
                        <tr> 
                            <td class="ScheduledTaskBody" style="width: 16px;">  
                                <img alt="Icon" src="./Images/icons/process.png" style="float: left;" /> 
                            </td> 
                            <td class="ScheduledTaskBody">  
                                <%# FormatText(Eval("process.Value").ToString())%> 
                            </td> 
                        </tr> 
                    </table> 
                </AppointmentTemplate> 
            </telerik:RadScheduler> 
The line where the problem is at: <%# FormatText(Eval("process.Value").ToString())%> <-- DataBinding: 'Telerik.Web.UI.Appointment' does not contain a property with the name 'process'.

and here the code for my datasources:

<asp:ObjectDataSource ID="dsSchedulesNames" runat="server" DeleteMethod="DeleteGroupScheduledTasks" 
    SelectMethod="ScheduleNames" TypeName="Otto.Process.AdminWeb.ScheduleList">  
    <DeleteParameters> 
        <asp:Parameter Name="Name" Type="String" /> 
    </DeleteParameters> 
</asp:ObjectDataSource> 
<asp:ObjectDataSource ID="dsSchedules" runat="server" DeleteMethod="DeleteSingleScheduledTask" 
    InsertMethod="InsertAppointment" SelectMethod="AllData" TypeName="Otto.Process.AdminWeb.ScheduleList" 
    UpdateMethod="UpdateAppointment">  
    <DeleteParameters> 
        <asp:Parameter Name="ID" Type="String" /> 
    </DeleteParameters> 
    <UpdateParameters> 
        <asp:Parameter Name="ID" Type="String" /> 
        <asp:Parameter Name="Subject" Type="String" /> 
        <asp:Parameter Name="Start" Type="DateTime" /> 
        <asp:Parameter Name="End" Type="DateTime" /> 
        <asp:Parameter Name="RecurrenceRule" Type="String" /> 
        <asp:Parameter Name="RecurrenceParentID" Type="Object" /> 
        <asp:Parameter Name="RecurrenceState" Type="Object" /> 
        <asp:Parameter Name="workflowTypeID" Type="Int32" /> 
    </UpdateParameters> 
    <InsertParameters> 
        <asp:Parameter Name="Subject" Type="String" /> 
        <asp:Parameter Name="Start" Type="DateTime" /> 
        <asp:Parameter Name="End" Type="DateTime" /> 
        <asp:Parameter Name="strRecurrenceRule" Type="String" /> 
        <asp:Parameter Name="RecurrenceParentID" Type="Object" /> 
        <asp:Parameter Name="RecurrenceState" Type="Object" /> 
        <asp:Parameter Name="workflowTypeID" Type="Int32" /> 
        <asp:Parameter Name="Enabled" Type="Boolean" /> 
        <asp:Parameter Name="Remarks" Type="String" /> 
    </InsertParameters> 
</asp:ObjectDataSource> 
<asp:ObjectDataSource ID="dsWorkFlows" runat="server"   
    SelectMethod="WorkFLowList"   
    TypeName="Otto.Process.AdminWeb.WorkFlows">  
</asp:ObjectDataSource> 


Someone got some tips on how to solve this?

Cheers WIm

5 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 31 Aug 2009, 11:05 AM
Hi Wim,

Please, try the following code for a resource type with name "process":
<AppointmentTemplate> 
   <%#Eval("Subject") %> 
       <hr /> 
   <%# Container.Appointment.Resources.GetResourceByType("process").Text%> 
</AppointmentTemplate> 
 

Let us know if you have further questions.

Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Wim Tra Kranen
Top achievements
Rank 1
answered on 01 Sep 2009, 08:47 PM
Hi Peter,

It worked like a charm, thank you very much!

Wim
0
Brenda Rueb
Top achievements
Rank 1
answered on 13 Apr 2012, 06:46 PM
Is there a variation for if they didn't pick a resource? I tried code above, get "Object reference not set to an instance of an object." We're not forcing them to pick resources, they are optional. Holidays don't have a poc :)

    
<telerik:RadScheduler ID="RadScheduler1" runat="server" DataDescriptionField="EventDescription"
   DataEndField="EventEnd" DataKeyField="EventId" DataRecurrenceField="EventRecurRule"
   DataRecurrenceParentKeyField="EventRecurParentId" DataSourceID="SqlDataSourceEvents"
   DataStartField="EventStart" DataSubjectField="EventSubject" EnableDescriptionField="True"
   Height="650px" Width="900px" WorkDayStartTime="07:30:00" DayStartTime="07:00:00"
   SelectedView="MonthView" 
   CustomAttributeNames="EventSiteLoc,EventBldgLoc,EventRoomLoc,ModifiedBy,LastUpdated" 
   style="margin-bottom: 2">
   <AppointmentTemplate>
      <div class="rsAptSubject">
         <%# Eval("Subject") %>
      </div>
      POC: <%# Container.Appointment.Resources.GetResourceByType("POC").Text%>
   </AppointmentTemplate>
   <ResourceTypes>
      <telerik:ResourceType DataSourceID="SqlDataSourceEventCategories" ForeignKeyField="EventCategory"
         KeyField="EvntCatId" Name="Event Category" TextField="EvntCategoryName" />
      <telerik:ResourceType DataSourceID="SqlDataSourcePOCList" ForeignKeyField="EventPOC"
         KeyField="UserGuid" Name="POC" TextField="UserNameDisplay" />
   </ResourceTypes>
</telerik:RadScheduler>
0
Peter
Telerik team
answered on 16 Apr 2012, 02:27 PM
Hello,

Please, refer to this demo.

CS aspx
<asp:Label ID="UserLabel" runat="server" Text='<%# Container.Appointment.Resources.GetResourceByType("User") == null ? "None" : Container.Appointment.Resources.GetResourceByType("User").Text %>' />

VB.NET aspx:
<asp:Label ID="UserLabel" runat="server" Text='<%# If (Container.Appointment.Resources.GetResourceByType("User") is Nothing, "None" , Container.Appointment.Resources.GetResourceByType("User").Text) %>'></asp:Label>


Greetings,
Peter
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
Brenda Rueb
Top achievements
Rank 1
answered on 16 Apr 2012, 05:25 PM
Thanks Peter,
don't know how I missed the nice bold red text everytime I looked at that example!
Sure appreciate the patience you have.
Brenda
Tags
Scheduler
Asked by
Wim Tra Kranen
Top achievements
Rank 1
Answers by
Peter
Telerik team
Wim Tra Kranen
Top achievements
Rank 1
Brenda Rueb
Top achievements
Rank 1
Share this question
or