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

Accessing resource collection in AppointmentInsert

2 Answers 188 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
jford
Top achievements
Rank 1
jford asked on 15 Jan 2008, 02:50 PM
Hi,

I have a RadScheduler with a custom-templated inline insert form.  I have one resource, called "Type".  ASPX markup below:

<telerik:RadScheduler ID="RadScheduler1" runat="server" AllowDelete="True" AllowEdit="True" AllowInsert="True" DataEndField="EndTime" DataKeyField="VacationID" DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID" DataSourceID="SqlDataSource1" DataStartField="Start" DataSubjectField="Subject" DayStartTime="09:00:00" HoursPanelTimeFormat="h:mm tt" SelectedDate="2007-11-12" SelectedView="MonthView" WorkDayEndTime="18:00:00" WorkDayStartTime="09:00:00" Height="600px" OnAppointmentCreated="RadScheduler1_AppointmentCreated" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
    <ResourceTypes> 
<telerik:ResourceType KeyField="VacationTypeID" Name="Type" TextField="VacationType" ForeignKeyField="AppointmentTypeID" DataSourceID="SqlDataSource3" /> 
   </ResourceTypes> 
<InlineInsertTemplate> 
   <asp:TextBox 
       ID="TitleTextBox" 
       runat="server" 
       Text='<%# Bind("Subject") %>' 
       Width="90%" 
       TextMode="MultiLine" 
       Height="20px"
   </asp:TextBox> 
<asp:DropDownList 
               runat="server" 
               ID="TypesList" 
               DataValueField="VacationTypeID" 
               DataSourceID="SqlDataSource3" 
               SelectedValue = '<%# Bind("Type") %>' 
               DataTextField="VacationType" 
               > 
           </asp:DropDownList> 
 
   <asp:LinkButton 
       ID="InsertButton" 
       runat="server" 
       CommandName="Insert"
           Insert 
           </asp:LinkButton>&nbsp; 
           <asp:LinkButton 
               ID="InsertCancelButton" 
               runat="server" 
               CausesValidation="False" 
               CommandName="Cancel"
                   Cancel 
           </asp:LinkButton> 
     
</InlineInsertTemplate> 
    <AppointmentTemplate> 
        <%# Eval("Subject") %> (<%# Eval("Type.Text") %>
    </AppointmentTemplate> 
            </telerik:RadScheduler> 
            <br /> 
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:razzaConnectionString %>" 
                DeleteCommand="DELETE FROM Vacations WHERE (VacationID = @VacationID)" InsertCommand="INSERT INTO Vacations(Subject, Start, EndTime, UserID, RoomID, RecurrenceRule, RecurrenceParentID, AppointmentTypeID) VALUES (@Subject, @Start, @EndTime, @UserID, 1, @RecurrenceRule, @RecurrenceParentID, @AppointmentTypeID)" 
                SelectCommand="SELECT Vacations.*, VacationTypes.VacationType as TypeName FROM Vacations INNER JOIN VacationTypes ON VacationTypes.VacationTypeID=Vacations.AppointmentTypeID" 
                UpdateCommand="UPDATE Vacations SET Subject = @Subject, Start = @Start, EndTime = @EndTime, RoomID = 1, RecurrenceRule = @RecurrenceRule, RecurrenceParentID = @RecurrenceParentID, AppointmentTypeID=@AppointmentTypeID WHERE VacationID=@VacationID"
                <DeleteParameters> 
                    <asp:Parameter Name="VacationID" /> 
                    <asp:Parameter Name="Subject" /> 
                    <asp:Parameter Name="Start" /> 
                    <asp:Parameter Name="EndTime" /> 
                    <asp:Parameter Name="UserID" /> 
                    <asp:Parameter Name="RecurrenceRule" /> 
                    <asp:Parameter Name="RecurrenceParentID" /> 
            <asp:Parameter Name="AppointmentTypeID" /> 
                </DeleteParameters> 
                <UpdateParameters> 
                    <asp:Parameter Name="Subject" /> 
                    <asp:Parameter Name="Start" /> 
                    <asp:Parameter Name="EndTime" /> 
                    <asp:Parameter Name="UserID" /> 
                    <asp:Parameter Name="RecurrenceRule" /> 
                    <asp:Parameter Name="RecurrenceParentID" /> 
                    <asp:Parameter Name="VacationID" /> 
            <asp:Parameter Name="AppointmentTypeID" /> 
                </UpdateParameters> 
            </asp:SqlDataSource> 
        </div> 
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:razzaConnectionString %>" 
            SelectCommand="SELECT [EmployeeID], [EmployeeName] FROM [Prezza_Employees]"></asp:SqlDataSource> 
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:razzaConnectionString %>" 
            SelectCommand="SELECT [VacationTypeID], [VacationType] FROM [VacationTypes]"></asp:SqlDataSource> 
    </form> 

I am using the AppointmentInsert event handler to perform a custom-insert method.  I am having trouble, however, programatically accessing the value of the DropDownList "TypesList", which is bound to my resource "Type", in my inline insert form.  Could you provide me with a code example of how this is done.

2 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 15 Jan 2008, 03:55 PM
Hello James,

You should handle the AppointmentCommand event. You can then access the form container and use FindControl to locate the DropDownList. For example:

protected void RadScheduler1_AppointmentCommand(object sender, Telerik.Web.UI.AppointmentCommandEventArgs e) 
    if (e.CommandName == "Insert"
    { 
        DropDownList typesDropDown = e.Container.FindControl("TypesList"as DropDownList; 
        if (typesDropDown != null
        { 
            int vacationTypeId = Convert.ToInt32(typesDropDown.SelectedValue); 
            // ... 
        } 
    } 
 


Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Valentin Kononen
Top achievements
Rank 1
answered on 07 Aug 2008, 06:20 PM
Things get more tricky if you have embedded, say, a CheckBoxList inside a RadMenu.

I can find the RadMenu inside the container but had to hunt down the CheckBoxList:

CheckBoxList cbl = e.Container.FindControl("RadMenu").Controls(0).Controls(0).FindControl("CheckBoxList")

-mika-
Tags
Scheduler
Asked by
jford
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Valentin Kononen
Top achievements
Rank 1
Share this question
or