How to Insert the Room and User Details in to DB using SqlDataSource?

2 posts, 0 answers
  1. Saravanan
    Saravanan avatar
    6 posts
    Member since:
    Oct 2012

    Posted 26 Oct 2012 Link to this post

    Hi,
    I can able to insert the Appointment details in DB. But I couldn't able Insert both Room and User Details. Please find the below code for your review and help me out for the same.


    /*------------------------------------------------------------------------------------------------------------------*/
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestRADScheduler.aspx.cs" Inherits="TestRADScheduler" %>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:SqlDataSource ID="RoomsDataSource" runat="server"
                ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
                SelectCommand="SELECT [ID], [RoomName] FROM [Rooms]" DeleteCommand="DELETE FROM Rooms WHERE (ID = @ID)"
                InsertCommand="INSERT INTO Rooms(RoomName) VALUES (@RoomName)" UpdateCommand="UPDATE Rooms SET RoomName = @RoomName">
                <DeleteParameters>
                    <asp:Parameter Name="ID" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="RoomName" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="RoomName" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="sqlUserDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
                SelectCommand="SELECT [ID], [UserName] FROM [Users]"
                DeleteCommand="DELETE FROM Users WHERE (ID = @ID)"
                InsertCommand="INSERT INTO Users(ID, UserName) VALUES (@ID, @UserName)"
                UpdateCommand="UPDATE Users SET ID = @ID, UserName = @UserName">
                <DeleteParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                    <asp:Parameter Name="UserName" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                    <asp:Parameter Name="UserName" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>


            <asp:SqlDataSource ID="sqlDSAppointment" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
                DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = @ID"
                InsertCommand="INSERT INTO Appointments(Subject, Start, [End], RecurrenceRule, RecurrenceParentID, Description, RoomID, Reminder) VALUES (@Subject, @Start, @End , @RecurrenceRule, @RecurrenceParentID, @Description, @RoomID, @Reminder)"
                SelectCommand="SELECT ID, Subject, Start, [End], RecurrenceRule, RecurrenceParentID, Description, RoomID, Reminder FROM Appointments"
                UpdateCommand="UPDATE Appointments SET Subject = @Subject, Start = @Start, [End] = @End , RecurrenceRule = @RecurrenceRule, RecurrenceParentID = @RecurrenceParentID, Description = @Description, RoomID = @RoomID, Reminder = @Reminder WHERE (ID = @ID)">


                <DeleteParameters>
                    <asp:Parameter Name="ID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Subject" Type="String" />
                    <asp:Parameter Name="Start" Type="DateTime" />
                    <asp:Parameter Name="End" Type="DateTime" />
                    <asp:Parameter Name="RecurrenceRule" Type="String" />
                    <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
                    <asp:Parameter Name="Description" Type="String" />
                    <asp:Parameter Name="RoomID" Type="Int32" />
                    <asp:Parameter Name="Reminder" Type="String" />
                    <asp:Parameter Name="ID" 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="RecurrenceRule" Type="String" />
                    <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
                    <asp:Parameter Name="Description" Type="String" />
                    <asp:Parameter Name="RoomID" Type="Int32" />
                    <asp:Parameter Name="Reminder" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="radScheduler" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadScheduler ID="radScheduler" runat="server" AdvancedForm-EnableCustomAttributeEditing="true" EnableResourceEditing="true" DataDescriptionField="Description" DataEndField="End" DataKeyField="ID"
                DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID" DataReminderField="Reminder" 
                DataSourceID="sqlDSAppointment" DataStartField="Start" DataSubjectField="Subject" EnableDescriptionField="True" Height=""
                >
                <Reminders Enabled="True" />
                <AdvancedForm EnableCustomAttributeEditing="True" />
                
                <ResourceTypes >
                    <telerik:ResourceType AllowMultipleValues="true"  DataSourceID="RoomsDataSource" ForeignKeyField="RoomID"
                        KeyField="ID" Name="Room" TextField="RoomName" />
                    <telerik:ResourceType DataSourceID="sqlUserDataSource" ForeignKeyField="ID" KeyField="ID" Name="Users" TextField="UserName" />
                </ResourceTypes >
                <ResourceStyles >
                    <telerik:ResourceStyleMapping Type="Room"  ApplyCssClass="rsCategoryOrange" Text="Room 101" Key="ID"  />
                    <telerik:ResourceStyleMapping Type="Room" ApplyCssClass="rsCategoryGreen" Text="Room 102" Key="RoomID"/>
                    <telerik:ResourceStyleMapping Type="Room" ApplyCssClass="rsCategoryPink" Text="Room 201" Key="RoomID"/>
                    <telerik:ResourceStyleMapping Type="Room" ApplyCssClass="rsCategoryViolet" Text="Room 202" Key="RoomID"/>
                </ResourceStyles>


    <WebServiceSettings>
    <ODataSettings InitialContainerName=""></ODataSettings>
    </WebServiceSettings>
            </telerik:RadScheduler>
        </div>


        </form>
    </body>
    </html>


    Regards,
    Saravanan M
  2. Plamen
    Admin
    Plamen avatar
    2954 posts

    Posted 31 Oct 2012 Link to this post

    Hi Saravanan,

     
    Such insert  of the resources in RadScheduler is currently not supported directly from the mark up. If you want to perform some changes we recommend achieving it in the code behind.

    You can also review this help topic where is explained how to work with resources.

    Hoe this will be helpful.

    Regards,
    Plamen
    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.
Back to Top