Help with ResourceType value in an InlineInsertTemplate

5 posts, 0 answers
  1. RageMonkeyRage
    RageMonkeyRage avatar
    3 posts
    Member since:
    Aug 2009

    Posted 19 Aug 2010 Link to this post

    I have the following code wit an inlineEditTemplate. I am not getting the correct value for the AppointmentTypeID on appointment insert.  The value is always one, regardless of the value selected in the radcombobox. What Am I missing or doing wrong?
    <%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="WorkPlanProject.Master"
        CodeBehind="PersonalCalendar.aspx.vb" Inherits="WQS_Presentation.PersonalCalendar"
        Title="Calendar" %>
      
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <link href="../StyleSheets/VesselSheet.css" rel="stylesheet" type="text/css" />
        <link href="../StyleSheets/welcome.css" type="text/css" />
      
        <script src="../Scripts/jquery-1.4.2.js" type="text/javascript"></script>
      
        <script src="../Scripts/welcome.js" type="text/javascript"></script>
      
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
      
        <script type="text/javascript">
      
            /* Firefox resize scrollable content */
            function hideScrollableArea(sender, eventArgs) {
                if ($telerik.isFirefox)
                    $telerik.$('.rsContentScrollArea').css('overflow', 'hidden');
            }
            function showScrollableArea(sender, eventArgs) {
                if ($telerik.isFirefox)
                    $telerik.$('.rsContentScrollArea').css('overflow', 'auto');
            }
           
        </script>
      
        <div>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Office2007" />
            <div>
                <div>
                    My Schedule</div>
                <telerik:RadSplitter runat="server" ID="RadSplitter1" PanesBorderSize="0" Width="734px"
                    Height="552px" Skin="Office2007">
                    <telerik:RadPane runat="Server" ID="leftPane" Width="240px" MinWidth="240" MaxWidth="300"
                        Scrolling="None" OnClientResizing="hideScrollableArea" OnClientResized="showScrollableArea"
                        OnClientExpanding="hideScrollableArea" OnClientExpanded="showScrollableArea"
                        OnClientCollapsing="hideScrollableArea" OnClientCollapsed="showScrollableArea">
                        <div>
                            <telerik:RadCalendar runat="server" ID="RadCalendar1" Skin="Office2007" AutoPostBack="true"
                                EnableMultiSelect="false" DayNameFormat="FirstTwoLetters" EnableNavigation="true"
                                EnableMonthYearFastNavigation="false" OnSelectionChanged="RadCalendar1_SelectionChanged"
                                OnDefaultViewChanged="RadCalendar1_DefaultViewChanged">
                            </telerik:RadCalendar>
                            <telerik:RadCalendar runat="server" ID="RadCalendar2" Skin="Office2007" AutoPostBack="true"
                                EnableMultiSelect="false" DayNameFormat="FirstTwoLetters" EnableNavigation="false"
                                EnableMonthYearFastNavigation="false" OnSelectionChanged="RadCalendar2_SelectionChanged">
                            </telerik:RadCalendar>
                            <asp:SqlDataSource ID="SqlDSAppointmentTypes" runat="server" ConnectionString="<%$ ConnectionStrings:DATACOREConnectionString %>"
                                SelectCommand="usp_UIGetAppointmentTypes" SelectCommandType="StoredProcedure">
                            </asp:SqlDataSource>
                        </div>
                        <telerik:RadPanelBar runat="server" Skin="Office2007" ID="PanelBar" Width="100%">
                            <Items>
                                <telerik:RadPanelItem runat="server" Text="My Team Calendars" Expanded="true">
                                    <Items>
                                        <telerik:RadPanelItem runat="server">
                                            <ItemTemplate>
                                                <div>
                                                    <div>
                                                        <asp:CheckBox ID="chkDevelopment" runat="server" Text="Development" Checked="true"
                                                            AutoPostBack="true" OnCheckedChanged="CheckBoxes_CheckedChanged" />
                                                    </div>
                                                    <div>
                                                        <asp:CheckBox ID="chkMarketing" runat="server" Text="Marketing" Checked="true" AutoPostBack="true"
                                                            OnCheckedChanged="CheckBoxes_CheckedChanged" />
                                                    </div>
                                                    <div>
                                                        <asp:CheckBox ID="CheckBox1" runat="server" Text="Inspections" Checked="true" AutoPostBack="true"
                                                            OnCheckedChanged="CheckBoxes_CheckedChanged" />
                                                    </div>
                                                </div>
                                            </ItemTemplate>
                                        </telerik:RadPanelItem>
                                    </Items>
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem runat="server" Text="My Calendar" Expanded="true">
                                    <Items>
                                        <telerik:RadPanelItem runat="server">
                                            <ItemTemplate>
                                                <div>
                                                    <div>
                                                        <asp:CheckBox ID="chkQ1" runat="server" Text="Personal" Checked="true" AutoPostBack="true"
                                                            OnCheckedChanged="CheckBoxes_CheckedChanged" />
                                                    </div>
                                                    <div>
                                                        <asp:CheckBox ID="chkQ2" runat="server" Text="Work" Checked="true" AutoPostBack="true"
                                                            OnCheckedChanged="CheckBoxes_CheckedChanged" />
                                                    </div>
                                                </div>
                                            </ItemTemplate>
                                        </telerik:RadPanelItem>
                                    </Items>
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelBar>
                    </telerik:RadPane>
                    <telerik:RadSplitBar runat="server" ID="RadSplitBar2" CollapseMode="Forward" />
                    <telerik:RadPane runat="Server" ID="rightPane" Scrolling="None" Width="590px">
                        <telerik:RadScheduler runat="server" ID="RadScheduler1" Skin="Office2007" Height="551px"
                            ShowFooter="true" DayStartTime="08:00:00" DayEndTime="21:00:00" FirstDayOfWeek="Monday"
                            LastDayOfWeek="Friday" EnableDescriptionField="true" DataKeyField="AppointmentID"
                            DataSubjectField="AppointmentSubject" DataStartField="AppointmentStartDate" DataEndField="AppointmentEndDate"
                            AppointmentStyleMode="Default" OnNavigationComplete="RadScheduler1_NavigationComplete"
                            OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" OnAppointmentDelete="RadScheduler1_AppointmentDelete"
                            OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
                            EnableCustomAttributeEditing="true" AdvancedForm-Enabled="true">
                            <AdvancedForm Modal="false" DateFormat="M/d/yyyy" TimeFormat="h:mm tt" Enabled="true" />
                            <TimelineView UserSelectable="false" />
                            <ResourceTypes>
                                <telerik:ResourceType KeyField="AppointmentTypeID" Name="AppointmentTypes" TextField="AppointmentTypeName"
                                    ForeignKeyField="AppointmentTypeID" DataSourceID="SqlDSAppointmentTypes" />
                                <telerik:ResourceType KeyField="AppointmentOwnerID" Name="User" TextField="UserName"
                                    ForeignKeyField="AppointmentOwnerPersonID" />
                            </ResourceTypes>
                            <ResourceStyles>
                                <%--AppointmentStyleMode must be explicitly set to Default (see above) otherwise setting BackColor/BorderColor
                             will switch the appointments to Simple rendering (no rounded corners and gradients)--%>
                                <telerik:ResourceStyleMapping Type="Calendar" Text="Development" BackColor="#D0ECBB"
                                    BorderColor="#B0CC9B" />
                                <telerik:ResourceStyleMapping Type="Calendar" Text="Marketing" ApplyCssClass="rsCategoryRed" />
                                <telerik:ResourceStyleMapping Type="Calendar" Text="Work" ApplyCssClass="rsCategoryOrange" />
                            </ResourceStyles>
                            <AppointmentTemplate>
                                <span style="font-weight: bold; font-size: xx-small">
                                    <br />
                                    <h2>
                                        <%# Eval("Subject") %></h2>
                                </span>
                                <br />
                                <b>Starts on: </b><%# Eval("Start")%>   <b>Ends on: </b><%# Eval("End") %>  
                            </AppointmentTemplate>
                            <InlineInsertTemplate>
                                <div>
                                    <table width="734px">
                                        <tr>
                                            <td>
                                                <%--Subject--%>
                                                <asp:Label ID="lblSubject" Text="Subject: " runat="server" Font-Bold="true" Font-Size="XX-Small"></asp:Label>
                                                <telerik:RadTextBox ID="RadTextBox1" runat="server" Skin="Sunset" Text='<%# Bind("Subject") %>'>
                                                </telerik:RadTextBox>
                                            </td>
                                        </tr>
                                        <%--Start and End times--%>
                                        <tr>
                                            <td>
                                                <asp:Label ID="lblStartOn" runat="server" Font-Size="XX-Small" Text="Starts on" Font-Bold="true"></asp:Label>
                                                <telerik:RadDateTimePicker ID="RadDateTimePicker1" Font-Size="XX-Small" Skin="Sunset"
                                                    runat="server" SelectedDate='<%# Bind("Start")%>'>
                                                </telerik:RadDateTimePicker>
                                                <asp:Label ID="lblEndOn" runat="server" Font-Size="XX-Small" Text="Ends on" Font-Bold="true"></asp:Label>
                                                <telerik:RadDateTimePicker ID="RadDateTimePicker2" Font-Size="XX-Small" Skin="Sunset"
                                                    runat="server" SelectedDate='<%# Bind("End")%>'>
                                                </telerik:RadDateTimePicker>
                                                <br />
                                                <telerik:RadComboBox ID="ddlAppointmentType" 
                                                    runat="server" DataSourceID="SqlDSAppointmentTypes" DataTextField="AppointmentTypeName"
                                                    DataValueField="AppointmentTypeID" AutoPostBack="true">
                                                </telerik:RadComboBox>
                                                <%--Ok and cancel buttons floated right--%>
                                                <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert">
                                                    <asp:Image runat="server" ID="insertImage" ImageUrl="~/Images/Buttons/ok_checkmark_green.png"
                                                        AlternateText="insert" />
                                                </asp:LinkButton>
                                                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel">
                                                    <asp:Image runat="server" ID="Image2" ImageUrl="~/Images/Buttons/CancelItem.png"
                                                        AlternateText="cancel" />
                                                </asp:LinkButton>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </InlineInsertTemplate>
                            <InlineEditTemplate>
                                <div>
                                    <table width="734px">
                                        <tr>
                                            <td>
                                                <%--Subject--%>
                                                <asp:Label ID="lblSubject" Text="Subject: " runat="server" Font-Bold="true" Font-Size="XX-Small"></asp:Label>
                                                <telerik:RadTextBox ID="RadTextBox1" runat="server" Skin="Sunset" Text='<%# Bind("Subject") %>'>
                                                </telerik:RadTextBox>
                                            </td>
                                        </tr>
                                        <%--Start and End times--%>
                                        <tr>
                                            <td>
                                                <asp:Label ID="lblStartOn" runat="server" Font-Size="XX-Small" Text="Starts on" Font-Bold="true"></asp:Label>
                                                <telerik:RadDateTimePicker ID="RadDateTimePicker1" Font-Size="XX-Small" Skin="Sunset"
                                                    runat="server" SelectedDate='<%# Bind("Start")%>'>
                                                </telerik:RadDateTimePicker>
                                                <asp:Label ID="lblEndOn" runat="server" Font-Size="XX-Small" Text="Ends on" Font-Bold="true"></asp:Label>
                                                <telerik:RadDateTimePicker ID="RadDateTimePicker2" Font-Size="XX-Small" Skin="Sunset"
                                                    runat="server" SelectedDate='<%# Bind("End")%>'>
                                                </telerik:RadDateTimePicker>
                                                <%--Ok and cancel buttons floated right--%>
                                                <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert">
                                                    <asp:Image runat="server" ID="insertImage" ImageUrl="~/Images/Buttons/ok_checkmark_green.png"
                                                        AlternateText="insert" />
                                                </asp:LinkButton>
                                                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel">
                                                    <asp:Image runat="server" ID="Image2" ImageUrl="~/Images/Buttons/CancelItem.png"
                                                        AlternateText="cancel" />
                                                </asp:LinkButton>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </InlineEditTemplate>
                            <TimeSlotContextMenuSettings EnableDefault="true" />
                            <AppointmentContextMenuSettings EnableDefault="true" />
                        </telerik:RadScheduler>
                        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                            <AjaxSettings>
                                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                                    <UpdatedControls>
                                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
                                    </UpdatedControls>
                                </telerik:AjaxSetting>
                            </AjaxSettings>
                        </telerik:RadAjaxManager>
                    </telerik:RadPane>
                </telerik:RadSplitter>
            </div>
        </div>
    </asp:Content>
    And the Code Behind:
    Imports System
    Imports Telerik.Web.UI
    Imports System.Web.UI.WebControls
    Imports Telerik.Web.UI.Calendar
    Imports System.Collections.Generic
    Imports System.ComponentModel
    Imports System.IO
      
    Partial Public Class PersonalCalendar
        Inherits System.Web.UI.Page
        Private AppointmentManager As New ABC_BusinessRules.ApointmentManager
        Private Const ProviderSessionKey As String = "Telerik.Web.Examples.Scheduler.Outlook2007.DefaultCS"
        Private checkBoxIDs As Dictionary(Of Integer, String)
        
          
      
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            ' BindSchedular(DateTime.Today)
            checkBoxIDs = New Dictionary(Of Integer, String)()
            checkBoxIDs.Add(1, "chkDevelopment")
            checkBoxIDs.Add(2, "chkMarketing")
            checkBoxIDs.Add(3, "chkQ1")
            checkBoxIDs.Add(4, "chkQ2")
            'BindSchedular(RadScheduler1.SelectedDate)
            If Not IsPostBack Then
                BindSchedular(RadScheduler1.SelectedDate)
                RadCalendar1.SelectedDate = RadScheduler1.SelectedDate
                SyncCalendars()
            End If
      
            
      
        End Sub
        Protected Sub RadScheduler1_NavigationComplete(ByVal sender As Object, ByVal e As SchedulerNavigationCompleteEventArgs)
            RadCalendar1.FocusedDate = RadScheduler1.SelectedDate
            SyncCalendars()
        End Sub
      
        Protected Sub RadCalendar1_DefaultViewChanged(ByVal sender As Object, ByVal e As DefaultViewChangedEventArgs)
            SyncCalendars()
        End Sub
      
        Private Sub SyncCalendars()
            RadCalendar2.FocusedDate = RadCalendar1.FocusedDate.AddMonths(1)
        End Sub
      
        Protected Sub RadCalendar1_SelectionChanged(ByVal sender As Object, ByVal e As SelectedDatesEventArgs)
            If RadCalendar1.SelectedDates.Count > 0 Then
                RadScheduler1.SelectedDate = RadCalendar1.SelectedDate
                RadCalendar2.SelectedDate = RadCalendar1.SelectedDate
            End If
        End Sub
      
        Protected Sub RadCalendar2_SelectionChanged(ByVal sender As Object, ByVal e As SelectedDatesEventArgs)
            If RadCalendar2.SelectedDates.Count > 0 Then
                RadScheduler1.SelectedDate = RadCalendar2.SelectedDate
                RadCalendar1.SelectedDate = RadCalendar2.SelectedDate
            End If
        End Sub
      
        Protected Sub RadScheduler1_AppointmentDataBound(ByVal sender As Object, ByVal e As SchedulerEventArgs)
            Dim radCalendarDay As New RadCalendarDay(RadCalendar1)
            radCalendarDay.[Date] = e.Appointment.Start
            radCalendarDay.ItemStyle.CssClass = "DayWithAppointments"
            RadCalendar1.SpecialDays.Add(radCalendarDay)
            RadCalendar2.SpecialDays.Add(radCalendarDay)
      
            e.Appointment.Visible = True
      
            For Each key As Integer In checkBoxIDs.Keys
                Dim chkBox As CheckBox = TryCast(PanelBar.Items(0).Items(0).FindControl(checkBoxIDs(key)), CheckBox)
                If chkBox Is Nothing Then
                    chkBox = TryCast(PanelBar.Items(1).Items(0).FindControl(checkBoxIDs(key)), CheckBox)
                End If
      
                If chkBox.Checked Then
                    Dim userRes As Resource = e.Appointment.Resources.GetResource("Calendar", key.ToString())
                    If userRes IsNot Nothing Then
                        e.Appointment.Visible = True
                    End If
      
                End If
      
      
      
            Next
        End Sub
        Protected Sub RadScheduler1_AppointmentDelete(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs)
            RadCalendar1.SpecialDays.Clear()
            RadCalendar2.SpecialDays.Clear()
        End Sub
        Protected Sub RadScheduler1_AppointmentUpdate(ByVal sender As Object, ByVal e As AppointmentUpdateEventArgs)
            RadCalendar1.SpecialDays.Clear()
            RadCalendar2.SpecialDays.Clear()
        End Sub
      
      
        Public Sub BindSchedular(ByVal SelectedDate As DateTime)
            'Get the Users Profile
            Dim strUserID As String
            Dim m As MembershipUser = Membership.GetUser()
            strUserID = m.UserName
            Dim iOwnerPersonID As Integer
            iOwnerPersonID = AppointmentManager.oDal.GetPersonIDbyUserName(strUserID)
            RadScheduler1.DataSource = AppointmentManager.GetAllItems(iOwnerPersonID)
            RadScheduler1.DataBind()
      
        End Sub
      
      
      
        Protected Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs)
            'If e.Appointment.Resources.Count < 1 Then
            '    e.Appointment.Resources.Add(RadScheduler1.Resources.GetResource("Calendar", "1"))
            'End If
            Dim AppointmentSet As New ABC_BusinessEntity.AppointmentSet
            Dim Appointment As New ABC_BusinessEntity.Appointment
            Dim dtAppointmentStart As DateTime
            Dim dtAppointmentEnd As DateTime
            Dim strAppointmentSubject As String
      
            'Subject
            If e.Appointment.Subject = String.Empty Then
                e.Cancel = True
                Exit Sub
            Else
                strAppointmentSubject = e.Appointment.Subject
            End If
            dtAppointmentStart = e.Appointment.Start
            dtAppointmentEnd = e.Appointment.End
      
            'Get the Users Profile
            Dim strUserID As String
            Dim m As MembershipUser = Membership.GetUser()
            strUserID = m.UserName
      
      
            'If e.Appointment.Resources.Count < 1 Then
            '    e.Appointment.Resources.Add(RadScheduler1.Resources.GetResource("AppointmentTypes", 1))
      
            'End If
      
            'If e.Appointment.Resources.GetResourceByType("AppointmentTypes") IsNot Nothing Then
            '    e.Appointment.Resources.Add(RadScheduler1.Resources.GetResource("AppointmentTypes", 1))
      
            'End If
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
            With Appointment
                '.AppointmentDescription=
                '.AppointmentDuration=
                .AppointmentEndDate = dtAppointmentEnd.ToUniversalTime
                '.AppointmentID=
                '.AppointmentLocationID=
                '.AppointmentLocationTypeID=
                .AppointmentOwnerPersonID = AppointmentManager.oDal.GetPersonIDbyUserName(strUserID)
                '.AppointmentRecurrenceParentID=
                '.AppointmentRecurrenceRuleID=
                .AppointmentRecurrenceState = 7
                '.AppointmentReminderID=
                .AppointmentResourceID = Nothing
                .AppointmentStartDate = dtAppointmentStart.ToUniversalTime
                .AppointmentSubject = strAppointmentSubject
                '.AppointmentTypeID = e.Appointment.Resources.GetResourceByType("AppointmentTypes").Key
      
                .AppointmentTypeID = RadScheduler1.Resources.GetResourceByType("AppointmentTypes").Key
      
      
      
      
                '.AppointmentTypeID = 
      
            End With
      
            'Insert into database...
            AppointmentSet.Add(Appointment)
            AppointmentManager.oDal.SaveAppointment(AppointmentSet)
            RadScheduler1.Rebind()
      
        End Sub
        Protected Sub ddlAppointmentType_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
      
        End Sub
        Protected Sub CheckBoxes_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
            RadScheduler1.Rebind()
        End Sub
      
        Private Sub RadScheduler1_AppointmentCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentCreatedEventArgs) Handles RadScheduler1.AppointmentCreated
            'Dim appointmenttype As Resource = e.Appointment.Resources.GetResourceByType("AppointmentTypes")
            'Dim cbo As New RadComboBox
            'cbo = DirectCast(e.Container.FindControl("ddlAppointmentType"), RadComboBox)
            'cbo.SelectedValue = appointmenttype.Key
      
        End Sub
      
          
      
        Private Sub RadScheduler1_AppointmentDelete1(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerCancelEventArgs) Handles RadScheduler1.AppointmentDelete
            Dim AppointmentID As Integer = e.Appointment.ID
            AppointmentManager.oDal.DeleteAppointment(AppointmentID)
            RadScheduler1.Rebind()
      
        End Sub
      
        Private Sub RadScheduler1_AppointmentUpdate1(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentUpdateEventArgs) Handles RadScheduler1.AppointmentUpdate
            Dim AppointmentSet As New ABC_BusinessEntity.AppointmentSet
            Dim Appointment As New ABC_BusinessEntity.Appointment
            Dim dtAppointmentStart As DateTime
            Dim dtAppointmentEnd As DateTime
            Dim strAppointmentSubject As String
      
            'Subject
      
            If e.ModifiedAppointment.Subject = String.Empty Then
                e.Cancel = True
                Exit Sub
            Else
                strAppointmentSubject = e.ModifiedAppointment.Subject
            End If
            dtAppointmentStart = e.ModifiedAppointment.Start
            dtAppointmentEnd = e.ModifiedAppointment.End
      
            'Get the Users Profile
            Dim strUserID As String
            Dim m As MembershipUser = Membership.GetUser()
            strUserID = m.UserName
      
            With Appointment
                .AppointmentID = e.ModifiedAppointment.ID
                '.AppointmentDescription=
                '.AppointmentDuration=
                .AppointmentEndDate = dtAppointmentEnd
                '.AppointmentID=
                '.AppointmentLocationID=
                '.AppointmentLocationTypeID=
                .AppointmentOwnerPersonID = AppointmentManager.oDal.GetPersonIDbyUserName(strUserID)
                '.AppointmentRecurrenceParentID=
                '.AppointmentRecurrenceRuleID=
                .AppointmentRecurrenceState = 7
                '.AppointmentReminderID=
                .AppointmentResourceID = Nothing
                .AppointmentStartDate = dtAppointmentStart
                .AppointmentSubject = strAppointmentSubject
                .AppointmentTypeID = 1
      
      
            End With
      
            'Update database...
            AppointmentSet.Add(Appointment)
            AppointmentManager.oDal.UpdateAppointment(AppointmentSet)
            RadScheduler1.Rebind()
        End Sub
      
        Protected Function GetAvailableUsers(ByVal container As Control) As IEnumerable
            Dim appointment As Appointment = (DirectCast(container, SchedulerFormContainer)).Appointment
      
            Dim availableUsers As New List(Of Resource)(RadScheduler1.Resources.GetResourcesByType("User"))
            For Each appointmentInRange As Appointment In RadScheduler1.Appointments.GetAppointmentsInRange(appointment.Start, appointment.[End])
                If appointmentInRange Is appointment Then
                    Continue For
                End If
      
                For Each occupiedUser As Resource In appointmentInRange.Resources.GetResourcesByType("User")
                    availableUsers.Remove(occupiedUser)
                Next
            Next
      
            Return availableUsers
        End Function
      
        Private Sub RadScheduler1_FormCreating(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerFormCreatingEventArgs) Handles RadScheduler1.FormCreating
            If e.Mode = SchedulerFormMode.Insert OrElse e.Mode = SchedulerFormMode.AdvancedInsert Then
                e.Appointment.Resources.Add(RadScheduler1.Resources.GetResourceByType("AppointmentTypes"))
            End If
      
        End Sub
      
        Private Sub RadScheduler1_NavigationComplete1(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerNavigationCompleteEventArgs) Handles RadScheduler1.NavigationComplete
      
        End Sub
      
       
          
      
       
      
          
      
         
      
        
    End Class



     

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 25 Aug 2010 Link to this post

    Hello CodeSlingerca,

    You need to bind the SelectedValue property of the resource RadComboBox. Please, take a look how this is done at this demo:
    <InlineEditTemplate>
              <asp:TextBox runat="server" ID="SubjectTextBox" Text='<%# Bind("Subject") %>' Width="99%"></asp:TextBox>
              <div class="UserToolbox">
              User: 
              <telerik:RadComboBox runat="server" ID="UsersComboBox" DataTextField="Text" DataValueField="Key"
                  Width="80px" Skin="Office2007" SelectedValue='<%# Bind("UserID") %>' DataSource="<%# GetAvailableUsers(Container) %>">
              </telerik:RadComboBox>

    UserID should be an existing field in the Appointments' data source:

    <sds:SessionDataSource ID="AppointmentsDataSource" runat="server" DisplayWarning="true"
               PrimaryKeyFields="ID" ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
               SelectCommand="SELECT * FROM [Appointments_ResourceAvailability]" InsertCommand="INSERT INTO [Appointments_ResourceAvailability] ([Subject], [Start], [End], [RoomID], [UserID]) VALUES (@Subject, @Start, @End , @RoomID, @UserID)"
               UpdateCommand="UPDATE [Appointments_ResourceAvailability] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [RoomID] = @RoomID, [UserID] = @UserID WHERE (ID = @ID)"
               DeleteCommand="DELETE FROM [Appointments_ResourceAvailability] WHERE [ID] = @ID">
               <DeleteParameters>
                   <asp:Parameter Name="ID" Type="Int32" />
               </DeleteParameters>
               <UpdateParameters>
                   <asp:Parameter Name="ID" Type="Int32" />
                   <asp:Parameter Name="Subject" Type="String" />
                   <asp:Parameter Name="Start" Type="DateTime" />
                   <asp:Parameter Name="End" Type="DateTime" />
                   <asp:Parameter Name="RoomID" Type="Int32" />
                   <asp:Parameter Name="UserID" 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="RoomID" Type="Int32" />
                   <asp:Parameter Name="UserID" Type="Int32" />
               </InsertParameters>
           </sds:SessionDataSource>



    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
  3. shahab
    shahab avatar
    58 posts
    Member since:
    Mar 2009

    Posted 27 May 2013 Link to this post

    I defined ResourceType as follow:

         <ResourceTypes>             <br>                    <telerik:ResourceType KeyField="Id" Name="Room" TextField="Name" ForeignKeyField="RoomId"<br>                        DataSourceID="RoomsEntityDataSource"></telerik:ResourceType><br>                </ResourceTypes>

    and I have an AdvancedEditTemplate to show selected Room in DropDownList:

    <br> <AdvancedEditTemplate><br>                    <div id="qsfexAdvEditWrapper" dir="rtl"><br>                        <div id="qsfexAdvEditInnerWrapper" class="technical"><br>                            <div class="qsfexAdvEditControlWrapper"><br>                                <asp:Label ID="RoomLabel" AssociatedControlID="RoomsComboBox" runat="server" CssClass="inline-label">محل حضور:</asp:Label><br>                                <br /><br>                                <telerik:RadComboBox runat="server" ID="RoomsComboBox" DataTextField="Name" DataValueField="Id"<br>                                    Width="97%" Skin="Office2007" SelectedValue='<%# Bind("RoomId") %>' DataSourceID="RoomsEntityDataSource"><br>                                </telerik:RadComboBox><br>                            </div><br></AdvancedEditTemplate>

    And DataSource to load Rooms:

       <asp:EntityDataSource ID="RoomsEntityDataSource" runat="server" ConnectionString="name=DatabaseEntities"<br>            DefaultContainerName="DatabaseEntities" CommandText="            <br>            (SELECT [Room].Name as Name, [Room].Id as Id<br>            From DatabaseEntities.Rooms as Room)<br>            UNION (SELECT NoSelection.Name,NoSelection.Id From DatabaseEntities.NoSelections as NoSelection)"><br>        </asp:EntityDataSource>

    but in EditForm SelectedRoom is not select by default.
        protected void DoctorsScheduler_FormCreating(object sender, SchedulerFormCreatingEventArgs e)<br>    {<br>        e.Appointment.Resources.Add(DoctorsScheduler.Resources.GetResourceByType("Room"));<br>    }

    What should I do?
  4. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 30 May 2013 Link to this post

    Hi shahab,

     
    In such case we recommend using a user control for  Advanced Template form as it is done in this on-line demo. You can find examples for this scenario in this Code Library.

    Hope this will be helpful.

    Regards,
    Plamen
    Telerik
    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.
  5. shahab
    shahab avatar
    58 posts
    Member since:
    Mar 2009

    Posted 30 May 2013 Link to this post

    hi
    I can not use user control. Please guide me on this type. I used user control before but I have a problem then I changed it.
    How can I find roomID for selected appointment and set it in runtime because I think there is no solution with binding?
    Why in default form everything is ok?
Back to Top