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

[Solved] Getting error after implimenting templates

3 Answers 153 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
mike john
Top achievements
Rank 1
mike john asked on 17 Feb 2010, 10:22 PM
Hi I have read this thread http://www.telerik.com/help/aspnet-ajax/schedule_appearancetemplates.html on using templates I would like to be able to use the radio buttons to assign the job to a dept

when I load the page I get the following error

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

this is my aspx
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<%@ Register assembly="System.Web.Ajax" namespace="System.Web.UI" tagprefix="asp" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
    <AppointmentTemplate> 
   <div class="rsCustomAppointmentContainer <%# Eval("AppointmentType.Text") %>"> 
       <h2><%# Eval("Subject") %> 
           <asp:AjaxScriptManager ID="AjaxScriptManager1" runat="server">  
           </asp:AjaxScriptManager> 
       </h2> 
   </div> 
</AppointmentTemplate>   
        <telerik:RadScheduler ID="RadScheduler1" runat="server"   
            CustomAttributeNames="fileUpload" DataDescriptionField="jobDescription"   
            DataEndField="jobEnd" DataKeyField="jobId" DataSourceID="SqlDataSource1"   
            DataStartField="jobLive" DataSubjectField="jobName" Skin="Windows7">  
            <ResourceStyles> 
                <telerik:ResourceStyleMapping ApplyCssClass="" Key="fileUpload" Text=""   
                    Type="url" /> 
            </ResourceStyles> 
        </telerik:RadScheduler> 
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"   
            ConnectionString="<%$ ConnectionStrings:JT2010ConnectionString %>"   
            SelectCommand="SELECT [jobId], [jobName], [jobType], [jobLive], [jobEnd], [jobDescription], [fileUpload], [UserId], [jobStatus], [jobCreated] FROM [Jobs] WHERE ([jobStatus] = @jobStatus)">  
            <SelectParameters> 
                <asp:Parameter DefaultValue="New" Name="jobStatus" Type="String" /> 
            </SelectParameters> 
        </asp:SqlDataSource> 
        <InlineInsertTemplate> 
   <div id="InlineInsertTemplate" class="rsCustomAppointmentContainer <%# Eval("AppointmentType.Text") %>"> 
       <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Subject") %>' Width="90%" TextMode="MultiLine" Height="20px"></asp:TextBox> 
   
       <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert">  
           <asp:Image runat="server" ID="insertImage" ImageUrl="Images/ok.gif" AlternateText="insert" /> 
       </asp:LinkButton> 
   
       <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel">  
       <asp:Image runat="server" ID="Image2" ImageUrl="Images/cancel.gif" AlternateText="cancel" /> 
       </asp:LinkButton> 
   
       <div class="inline-label">Color code:</div> 
   
       <asp:RadioButtonList runat="server" ID="AppointmentTypeRadioButtonList"   
           DataValueField="type" CssClass="AppointmentTypeSelectorTable" 
  DataSourceID="SqlDataSource2" SelectedValue='<%# Bind("AppointmentTypeID") %>' DataTextField="type" 
  RepeatDirection="Horizontal"   
           DataTextFormatString="<span class='AppointmentTypeSelector rsAptType_{0}' onclick='onAppointmentTypeSelectorClick'></span>">  
       </asp:RadioButtonList> 
   
       <asp:SqlDataSource ID="SqlDataSource2" runat="server"   
           ConnectionString="<%$ ConnectionStrings:JT2010ConnectionString %>"   
           SelectCommand="SELECT [id], [type] FROM [JobType]"></asp:SqlDataSource> 
   
       <asp:LinkButton ID="InsertMoreButton" runat="server" CommandName="More" CssClass="rsAdvancedEditLink">Advanced</asp:LinkButton> 
   </div> 
</InlineInsertTemplate>   
<InlineEditTemplate> 
   <div id="InlineEditTemplate" class="rsCustomAppointmentContainer <%# Eval("AppointmentType.Text") %>"> 
       <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Subject") %>' Width="90%" TextMode="MultiLine" Height="20px"></asp:TextBox> 
   
       <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Update">  
           <asp:Image runat="server" ID="Image6" ImageUrl="Images/ok.gif" AlternateText="update" /> 
       </asp:LinkButton> 
   
       <asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" CommandName="Cancel">  
           <asp:Image runat="server" ID="Image7" ImageUrl="Images/cancel.gif" AlternateText="cancel" /> 
       </asp:LinkButton> 
   
       <div class="inline-label">Color code:</div> 
   
       <asp:RadioButtonList runat="server" ID="RadioButtonList3" DataValueField="type" CssClass="AppointmentTypeSelectorTable" 
  DataSourceID="SqlDataSource2" SelectedValue='<%# Bind("AppointmentTypeID") %>' DataTextField="type" 
  RepeatDirection="Horizontal"   
           DataTextFormatString="<span class='AppointmentTypeSelector rsAptType_{0}' onclick='onAppointmentTypeSelectorClick'></span>">  
       </asp:RadioButtonList> 
   
       <asp:LinkButton ID="LinkButton5" runat="server" CommandName="More" CssClass="rsAdvancedEditLink">Advanced</asp:LinkButton> 
   </div> 
</InlineEditTemplate>    
 
    </div> 
    </form> 
</body> 
</html> 

VB
Imports System.Web  
Imports System.Web.UI.HtmlControls  
Imports System.Web.UI.WebControls  
Imports System.Web.ApplicationServices  
 
Partial Class users_Default4  
    Inherits System.Web.UI.Page  
 
 
    Protected Sub RadScheduler1_FormCreated(ByVal sender As Object, _  
                               ByVal e As SchedulerFormCreatedEventArgs)  
        If e.Container.Mode = SchedulerFormMode.Insert Then 
            Dim list As RadioButtonList = _  
                DirectCast(e.Container.FindControl("AppointmentTypeRadioButtonList"),  _  
                                                    RadioButtonList)  
            list.SelectedIndex = 0  
        End If 
    End Sub 
End Class 
 

thanks

M

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 19 Feb 2010, 05:30 PM
Hi mike,

The templates should we within RadScheduler. I realize that the help topic you have referred to shows only the templates code and not the entire context of RadScheduler so this might have confused you. Here is an online demo that better illustrates how to use and define templates:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/templates/defaultcs.aspx


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
mike john
Top achievements
Rank 1
answered on 19 Feb 2010, 06:02 PM
Thanks for the reply this gives the aspx.vb code do I just need an instance of rad scheduler on the aspx page (connected to db) ?

is it possible to get the source of the aspx file ?

thanks

M
0
Peter
Telerik team
answered on 23 Feb 2010, 11:23 AM
Hi Mike,

All the code (aspx, code-behind, etc.) can be viewed from the code tabs. Please, see the attached screenshot. The RadScheduler instance is defined in the aspx code and it is bound to a sample data source. Let me know if you have further questions.


All the best,
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
mike john
Top achievements
Rank 1
Answers by
Peter
Telerik team
mike john
Top achievements
Rank 1
Share this question
or