RadScheduler AdvancedForm breaking when customizing Location?

3 posts, 1 answers
  1. Adrian
    Adrian avatar
    4 posts
    Member since:
    Nov 2011

    Posted 28 Nov 2011 Link to this post

    Hi,

    I want to create a Scheduler with a color and location picker. The location list comes from my DB with an inline sql call to the DB. Also the RadScheduler has some inline sql calls to CRUD the calendar appointments. So I followed the example found at: http://demos.telerik.com/aspnet-ajax/scheduler/examples/advancedformtemplate/defaultcs.aspx

    I added my own datasource to the Room dropdown by altering the contents of ResourceControl.ascx to:

    <asp:Label runat="server" ID="ResourceLabel" AssociatedControlID="ResourceValue" Text='<%# Label %>' CssClass="rsAdvResourceLabel" /><!--
    --><telerik:RadComboBox runat="server" ID="ResourceValue" DataValueField="LCode" DataTextField="Location_Detail"
        CssClass="rsAdvResourceValue" Skin='<%# Skin %>'
        DataSourceID="SqlDataSource1" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:computershareConnectionString %>"
        SelectCommand="SELECT * FROM [LocationsTable]">
    </asp:SqlDataSource>

    My RadScheduler control in the Default.aspx looks like this:
    <telerik:RadScheduler runat="server" ID="RadScheduler1" Width="750px" Height="680px"
                    TimeZoneOffset="03:00:00"
                    OnDataBound="RadScheduler1_DataBound"
                    OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
                    OnClientFormCreated="schedulerFormCreated"
                    CustomAttributeNames="AppointmentColor"
                    EnableDescriptionField="True"
                    AppointmentStyleMode="Default" DataDescriptionField="Description"
                    DataEndField="EndTime" DataKeyField="ID" DataSourceID="SqlDataSource1"
                    DataStartField="StartTime" DataSubjectField="Subject">
                    <AdvancedForm Modal="true" />
                    <AppointmentTemplate>
                        <div class="rsAptSubject">
                            <%# Eval("Subject") %>
                        </div>
                        <%# Eval("Description") %>
                    </AppointmentTemplate>
                    <AdvancedEditTemplate>
                        <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit"
                            Subject='<%# Bind("Subject") %>'
                            Start='<%# Bind("StartTime") %>'
                            End='<%# Bind("End") %>'
                            Description='<%# Bind("Description") %>'
                            AppointmentColor='<%# Bind("AppointmentColor") %>'
                            RoomID='<%# Bind("Location_Code") %>' />
                    </AdvancedEditTemplate>
                    <AdvancedInsertTemplate>
                        <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert"
                            Subject='<%# Bind("Subject") %>'
                            Start='<%# Bind("StartTime") %>'
                            End='<%# Bind("End") %>'
                            Description='<%# Bind("Description") %>'
                            AppointmentColor='<%# Bind("AppointmentColor") %>'
                            RoomID='<%# Bind("Location_Code") %>' />
                    </AdvancedInsertTemplate>
                    <TimelineView UserSelectable="false" />
                    <TimeSlotContextMenuSettings EnableDefault="true" />
                    <AppointmentContextMenuSettings EnableDefault="true" />                    
                </telerik:RadScheduler>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                    ConnectionString="<%$ ConnectionStrings:computershareConnectionString %>"
                    SelectCommand="SELECT * FROM [MyTable]"
                    DeleteCommand="DELETE FROM [MyTable] WHERE [ID] = @ID"
                    InsertCommand="INSERT INTO [MyTable] ([StartTime], [EndTime], [Subject], [Description], [Location_Code], [AppointmentColor]) VALUES (@StartTime, @EndTime, @Subject, @Description, @Location_Code, @AppointmentColor)"
                    UpdateCommand="UPDATE [MyTable] SET [StartTime] = @StartTime, [EndTime] = @EndTime, [Subject] = @Subject, [Description] = @Description, [Location_Code] = @Location_Code, [AppointmentColor] = @AppointmentColor WHERE [ID] = @ID">
                    <DeleteParameters>
                        <asp:Parameter Name="ID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="StartTime" Type="String" />
                        <asp:Parameter Name="EndTime" Type="String" />
                        <asp:Parameter Name="Subject" Type="String" />
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="Location_Code" Type="String" />
                        <asp:Parameter Name="AppointmentColor" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="StartTime" Type="String" />
                        <asp:Parameter Name="EndTime" Type="String" />
                        <asp:Parameter Name="Subject" Type="String" />
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="Location_Code" Type="String" />
                        <asp:Parameter Name="AppointmentColor" Type="String" />
                        <asp:Parameter Name="ID" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>

    If I remove the RoomID from AdvancedEditTemplate and AdvancedInsertTemplate the whole process works just fine but I'm missing the location. What is the problem? What am I doing wrong?

    I also have to mention that LCode from [LocationTable] is the same as Location_Code from [MyTable].

    Thanks.
  2. Answer
    Plamen
    Admin
    Plamen avatar
    3049 posts

    Posted 01 Dec 2011 Link to this post

    Hi Adrian,

    I reviewed the code you pasted, but couldn't notice any wrong usage. You can refer to the Customize the Advanced Form with the Advanced Template User Controls Code Library. There is a sample project called SQLDataSource, which implements a similar functionality.  Please review it and make the appropriate changes to all the files where your resource is concerned.

    Hope this will be useful.

    Kind regards,
    Plamen Zdravkov
    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
  3. Adrian
    Adrian avatar
    4 posts
    Member since:
    Nov 2011

    Posted 04 Dec 2011 Link to this post

    Thank you Plamen.
Back to Top