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

AppointmentTemplate - problem adding custom field

3 Answers 143 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 11 Aug 2010, 02:53 PM
Hello,

I have followed the example: Creating and adding an appointment template dynamically and accessing the appointment object in the template class.

I have binded a RadScheduler control to an SqlDataSource and am able to display a RoomID in the appointment template but only if RoomID is from the same table as the SqlDataSource (Appointments in this case). However, I would like to display the RoomName value from another table: Rooms. Therefore I have modified the SelectCommand for the data source to perform an inner join on the two tables to obtain the RoomName from Rooms. See below:

SelectCommand="SELECT Appointments.ID, Appointments.Subject, Appointments.Description, Appointments.Start, Appointments.RoomID, Appointments.UserID, Appointments.RecurrenceRule, Appointments.[End], Appointments.Annotations, Appointments.Reminder, Appointments.RecurrenceParentID, Rooms.ID AS Expr1, Rooms.RoomName as rName FROM Appointments INNER JOIN Rooms ON Appointments.RoomID = Rooms.ID"

I am trying to display the value of 'rName' in the same way that the example in the above link displays 'Start', 'End' and 'Subject'. Ie:

<asp:Literal ID="AppointmentLocation" runat="server" Text='<%# Eval("rName") %>'></asp:Literal>

When I run the web application, I'm presented with the following error:

Server Error in '/' Application.

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'Telerik.Web.UI.Appointment' does not contain a property with the name 'rName'.

Source Error:

Line 30: 
Line 31: <!-- Room Name -->
Line 32: <asp:Literal ID="AppointmentLocation" runat="server" Text='<%# Eval("rName") %>'></asp:Literal>
Line 33:
Line 34: </AppointmentTemplate>

Source File: ...\Projects\WebApplication5\WebApplication5\Default.aspx    Line: 32




Please can you advise what I am doing wrong here?

Regards,
Anthony.

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Aug 2010, 03:30 PM
Hello Anthony,

Have you added a resource type to RadScheduler? Please, see this demo for reference:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/resources/defaultcs.aspx

You can display the resource name in AppointmentTemplate like so:

<AppointmentTemplate>
     <%#Container.Appointment.Resources.GetResourceByType("User").Text%>
 </AppointmentTemplate>


Greetings, 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
Anthony
Top achievements
Rank 1
answered on 11 Aug 2010, 03:53 PM
Thanks for helping a newbie!

I do have a ResourceType configured for the RadScheduler but didn't know to use the code you provided. The string in GetResourceByType() has to match up with the Member name of the item in the ResourceType Collection Editor.
0
Peter
Telerik team
answered on 11 Aug 2010, 04:32 PM
Hi Anthony,

Yes, it has to match with the resource name. For example, if you have the following resource type:

<ResourceTypes
<telerik:ResourceType KeyField="ID" Name="User" TextField="UserName" ForeignKeyField="UserID" 
DataSourceID="UsersDataSource" /> 
</ResourceTypes

Then you should use the following string:
<AppointmentTemplate
     <%#Container.Appointment.Resources.GetResourceByType("User").Text%> 
 </AppointmentTemplate>


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
Anthony
Top achievements
Rank 1
Answers by
Peter
Telerik team
Anthony
Top achievements
Rank 1
Share this question
or