Problems with showing Resource data in Appointment template

6 posts, 1 answers
  1. Wim Tra Kranen
    Wim Tra Kranen avatar
    16 posts
    Member since:
    Feb 2006

    Posted 28 Aug 2009 Link to this post

    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
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 31 Aug 2009 Link to this post

    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.
  3. Wim Tra Kranen
    Wim Tra Kranen avatar
    16 posts
    Member since:
    Feb 2006

    Posted 01 Sep 2009 Link to this post

    Hi Peter,

    It worked like a charm, thank you very much!

    Wim
  4. Brenda Rueb
    Brenda Rueb avatar
    12 posts
    Member since:
    Jul 2008

    Posted 13 Apr 2012 Link to this post

    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>
  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 16 Apr 2012 Link to this post

    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.
  6. Brenda Rueb
    Brenda Rueb avatar
    12 posts
    Member since:
    Jul 2008

    Posted 16 Apr 2012 Link to this post

    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
Back to Top