Insert error in RadScheduler - null value

20 posts, 0 answers
  1. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 20 Dec 2009 Link to this post

    Hi.
    I have followed the AdvancedForm tutorial (http://www.telerik.com/help/aspnet-ajax/schedule_advancedformtemplate.html), and I have managed to include a user control to invite colleagues to an event. However when I try to save the event I get the following error:
    Value cannot be null.
    Parameter name: value

    This is my Telerik RadScheduler:
      <telerik:RadScheduler runat="server" ID="RadScheduler1" Skin="Office2007" 
                            Height="551px" ShowFooter="false" ReadOnly="false" Localization-AdvancedCalendarToday="I dag" Localization-AdvancedCalendarCancel="Avbryt" 
                            Localization-AdvancedDescription="Beskrivelse" Localization-AdvancedDone="Fullfør" Localization-AdvancedSubject="Emne" 
                            TimeZoneOffset="00:00:00" WeekView-HeaderDateFormat="dd.MM.yyyy" 
                            DayStartTime="07:00:00" DayEndTime="21:00:00" Culture="nb-NO"                         
                            FirstDayOfWeek="Monday" LastDayOfWeek="Friday" 
                            EnableDescriptionField="true" Localization-Show24Hours="Vi 24 timer" Localization-ShowBusinessHours="Vis arbeidstid" HoursPanelTimeFormat="HH.mm" 
                            DataSourceID="sqlAppointments" DataRecurrenceField="RecurrenceRule" DataDescriptionField="Description" 
                            DataEndField="EndTime" DataKeyField="ID" DataRecurrenceParentKeyField="RecurrenceParentID" DataStartField="StartTime" 
                            DataSubjectField="Subject" OnFormCreated="RadScheduler1_FormCreated" OnClientFormCreated="schedulerFormCreated" 
                            OnNavigationComplete="RadScheduler1_NavigationComplete" 
                            OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" 
                            OnAppointmentDelete="RadScheduler1_AppointmentDelete" 
                            OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" 
                            OnAppointmentInsert="RadScheduler1_AppointmentInsert"
                            <AdvancedForm Modal="true" /> 
                            <TimelineView UserSelectable="false" /> 
                <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") %>' 
                        Description='<%# Bind("Description") %>'  
                        EventID='<%# Bind("ID") %>' 
                        Start='<%# Bind("Start") %>' 
                        End='<%# Bind("End") %>' 
                        RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' 
                        UserID='<%# getUserID() %>' 
                        PartnerID='<%# getPartnerID() %>' /> 
                </AdvancedEditTemplate> 
                <AdvancedInsertTemplate> 
                    <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert" 
                        Subject='<%# Bind("Subject") %>' 
                        Start='<%# Bind("Start") %>' 
                        End='<%# Bind("End") %>' 
                        Description='<%# Bind("Description") %>' 
                        RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' 
                        UserID='<%# getUserID() %>' 
                        PartnerID='<%# getPartnerID() %>' /> 
                </AdvancedInsertTemplate>             
             <TimeSlotContextMenuSettings EnableDefault="true" /> 
             <AppointmentContextMenuSettings EnableDefault="true" /> 
                        </telerik:RadScheduler> 


    This is my SqlDataSource:
    <asp:SqlDataSource ID="sqlAppointments" runat="server" ConnectionString='<%$ ConnectionStrings:ConnectionString %>' 
        SelectCommand="SELECT * FROM Appointments WHERE UserID = (SELECT TOP 1 UserID FROM User WHERE UserID_guid = @UserID) AND StartTime < EndTime" 
        InsertCommand="INSERT INTO [Appointments] ([Subject], [Start], [End], [UserID], [RecurrenceRule], [RecurrenceParentID], [Description]) VALUES (@Subject, @Start, @End, @UserID, @RecurrenceRule, @RecurrenceParentID, @Description)" 
        > 
        <SelectParameters> 
            <asp:Parameter Name="UserID" /> 
        </SelectParameters>         
        <InsertParameters> 
                <asp:Parameter Name="Subject" Type="String" /> 
                <asp:Parameter Name="Start" Type="DateTime" /> 
                <asp:Parameter Name="End" Type="DateTime" /> 
                <asp:Parameter Name="UserID" Type="Int32" /> 
                <asp:Parameter Name="RecurrenceRule" Type="String" /> 
                <asp:Parameter Name="RecurrenceParentID" Type="Int32" /> 
                <asp:Parameter Name="Description" Type="String" />     
        </InsertParameters> 
    </asp:SqlDataSource> 


    One last note:
    The error occurs even when I try to add an event from the inline-insert. So I believe this has more to do with the setup of the sqldatasource or perhaps the radscheduler.

    Looking forward to your help :)
  2. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 20 Dec 2009 Link to this post

    Hi again.
    I solved my original problem, but another one occured instantly ;)

    First, my problem was solved by erasing the content of the OnAppointmentInsert="RadScheduler1_AppointmentInsert", since I did not have any e.Appointment.Resources as in the tutorial mentioned.

    Now, however, the only data which is saved to my database when I insert an appointment with the inline-insert is the Subject. Start and EndTime is ignored, as well as UserID. Can someone please tell me why?

    Thanks in advance.
  3. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 20 Dec 2009 Link to this post

    Ok. I solved another problem, but still there is another problem: How can I read the data from my user control which is a part of the advancedForm user control?

    Here is how I solved the insert-saving problem:
        protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e) 
        { 
            sqlAppointments.InsertParameters["End"].DefaultValue = e.Appointment.End.ToString(); 
            sqlAppointments.InsertParameters["Start"].DefaultValue = e.Appointment.Start.ToString(); 
            sqlAppointments.InsertParameters["UserID"].DefaultValue = UserID.ToString(); 
            sqlAppointments.InsertParameters["Subject"].DefaultValue = e.Appointment.Subject.ToString(); 
            sqlAppointments.InsertParameters["Description"].DefaultValue = e.Appointment.Description.ToString(); 
            sqlAppointments.InsertParameters["RecurrenceRule"].DefaultValue = e.Appointment.RecurrenceRule.ToString(); 
            try 
            { 
                sqlAppointments.InsertParameters["RecurrenceParentID"].DefaultValue = Convert.ToInt32(e.Appointment.RecurrenceParentID.ToString()).ToString(); 
            } 
            catch(Exception exc) 
            { 
                sqlAppointments.InsertParameters["RecurrenceParentID"].DefaultValue = "0"
            }         
        } 

  4. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 21 Dec 2009 Link to this post

    Hi again.
    I am still struggling on how to refer to my user control inside the advanced form, from the .aspx-page containing the RadScheduler. The setup is basically as follows: Default.aspx -> RadScheduler -> AdvancedForm.ascx -> Colleagues.ascx -> DataList

    I need to run through my DataList inside the Colleagues user control in order to find which people who are invited to the appointment. The DataList items contains a simple checkbox with the colleague's name.

    I have used this tutorial () as my starting point. However, I would prefer to send a DataTable, instead of a String (don't know how to send all my data as a String...), and it seems CustomAttributes will not allow DataTable (?).

    Below is my code in Colleagues.ascx.cs:
        private DataTable _colleagues; 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)] 
        public DataTable colleagues 
        { 
            get  
            { 
                if (_colleagues == null) 
                    _colleagues = getColleagues(); 
     
                Session["colleagues"] = _colleagues; 
     
                return _colleagues;  
            } 
            set 
            { 
                _colleagues = getColleagues(); 
            } 
        } 
     
        public DataTable getColleagues() 
        { 
            //return selected colleagues: 
            DataTable objDT = new DataTable("Colleagues"); 
            objDT.Columns.Add("ID", Type.GetType("System.Int32")); 
            objDT.Columns["ID"].AutoIncrement = true
            objDT.Columns["ID"].AutoIncrementSeed = 1
     
            objDT.Columns.Add("UserID", Type.GetType("System.String")); 
            objDT.Columns.Add("Name", Type.GetType("System.String")); 
            objDT.Columns.Add("Email", Type.GetType("System.String")); 
     
            foreach (DataListItem item in dlColleagues.Items) 
            { 
                CheckBox chk = (CheckBox)item.FindControl("chkUser"); 
                if (chk.Checked) 
                { 
                    HiddenField hdnEmail = (HiddenField)item.FindControl("hdn1"); 
                    Label lbl = (Label)item.FindControl("lblNavn"); 
                    DataRow r = objDT.NewRow(); 
                    r["UserID"] = chk.ToolTip.ToString(); 
                    r["Name"] = lbl.Text.ToString(); 
                    r["Email"] = hdnEmail.Value.ToString(); 
                } 
            } 
     
            return objDT; 
        } 

    Below is the code in AdvancedForm.ascx.cs:
            [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)] 
            public DataTable Colleagues  
            { 
                get 
                { 
                    return (DataTable)ResColleagues.colleagues; 
                    //return (DataTable)Session["colleagues"]; 
                } 
                set 
                { 
                } 
            } 

    (I have tried both the session-approach and the none-session-approach.)
    ResColleagues is my resource control instantiated from the Colleagues User Control in AdvancedForm.ascx:
    <scheduler:Colleagues runat="server" ID="ResColleagues" /> 
     
    Below is some of my code in Default.aspx:
    <telerik:RadScheduler runat="server" ID="RadScheduler1" CustomAttributeNames="colleagues" EnableCustomAttributeEditing="true" OnAppointmentInsert="RadScheduler1_AppointmentInsert" 
    ...> 
    *** 
    </...> 

    And finally my code for Default.aspx.cs and the OnAppointmentInsert:
     
    protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)  
        {  
            sqlAppointments.InsertParameters["End"].DefaultValue = e.Appointment.End.ToString();  
            sqlAppointments.InsertParameters["Start"].DefaultValue = e.Appointment.Start.ToString();  
            sqlAppointments.InsertParameters["UserID"].DefaultValue = UserID.ToString();  
            sqlAppointments.InsertParameters["Subject"].DefaultValue = e.Appointment.Subject.ToString();  
            sqlAppointments.InsertParameters["Description"].DefaultValue = e.Appointment.Description.ToString();  
            sqlAppointments.InsertParameters["RecurrenceRule"].DefaultValue = e.Appointment.RecurrenceRule.ToString();  
            try  
            {  
                sqlAppointments.InsertParameters["RecurrenceParentID"].DefaultValue = Convert.ToInt32(e.Appointment.RecurrenceParentID.ToString()).ToString();  
            }  
            catch(Exception exc)  
            {  
                sqlAppointments.InsertParameters["RecurrenceParentID"].DefaultValue = "0";  
            }      
     
            try 
            { 
                //iterate the selected colleague 
                DataTable dt = (DataTable)e.Appointment.Attributes["colleagues"]; 
                //DataTable dt = (DataTable)Session["colleagues"]; 
                foreach (DataRow r in dt.Rows) 
                { 
                    string name = r["Name"].ToString(); 
                } 
            } 
            catch (Exception exc) 
            { 
            }         
             
        }  

    When using the e.Appointment.Attr.... an exception is thrown as it cannot convert a String to a DataTable.
    If I use the session-option the iteration causes an Exception as the DataTable does not contain any rows...
    What am I doing wrong?
    Looking forward to your advice.
  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 24 Dec 2009 Link to this post

    Hi R,

    If you need to display Colleagues as a checkbox list in the advanced form, you should consider creating a multi-valued resource type. Multi-valued resources are only supported via a special provider:
    http://www.telerik.com/help/aspnet-ajax/schedule_databindingimplementingaproviderthatsupportsmultivaluedresources.html

    Once you create your provider for multi-valued resources you can use it to replace the XmlSchedulerProvider from this kb article:
    http://www.telerik.com/support/kb/aspnet-ajax/scheduler/sample-project-of-the-customizing-the-advanced-template-example.aspx

    The user control which will display your Colleagues checkbox list is MultipleValuesResourceControl.

    Also, you should keep in mind that any resource type your create requires a separate data source. You cannot use the same data source to populate both appointments and resources. Here is a demo to use for reference:
    http://demos.telerik.com/aspnet-ajax/scheduler/examples/multipleresourcevalues/defaultcs.aspx

    If for some reason you cannot separate the resource data source from that of the appointment's data source you can use the following workaround:
    http://www.telerik.com/community/forums/aspnet-ajax/scheduler/group-by-in-timeline-view.aspx#895330



    Regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 03 Jan 2010 Link to this post

    Thanks for your reply.
    I have implemented a Colleagues.cs inside my AppCode-folder following the tutorial (Implementing A Provider That Supports Multi-valued Resources). Still there is one question bothering me.

    How may I implement the abstract class inherited from DbSchedulerProviderBase?
    public abstract class DbSchedulerProviderBase : SchedulerProviderBase 
      public override bool SupportsMultipleResourceValues { get { return true; } } 
      protected DbProviderFactory DbFactory { get { ... }; set { ... }; } 
      protected bool PersistChanges { get { ... }; set { ... }; } 
      protected string ConnectionString { get { ... }; set { ... }; } 
      public override void Initialize(string name, NameValueCollection config) { ... } 
      protected virtual DbConnection OpenConnection() { ... } 
      protected virtual DbParameter CreateParameter(string name, object value) { ... } 
    }   

    I first got a "System.NullReferenceException: Object reference  not set to an instance of an object." error on each
    using (DbConnection conn = OpenConnection())
    This was avoided by adding the code:
    protected override DbConnection OpenConnection() 
        SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["MyConnectionString"].ToString()); 
        return conn; 
     
    Now, my next error originates from the DbFactory, "System.NullReferenceException: Object reference not set to an instance of an object." error on each: 
    DbCommand cmd = DbFactory.CreateCommand();

    I hope you may answer me quickly, as I need to investigate this before the trial period ends (after which I must make a decision whether to purchase your RadControls).

    Thanks in advance.
  7. T. Tsonev
    Admin
    T. Tsonev avatar
    2815 posts

    Posted 06 Jan 2010 Link to this post

    Hi,

    The help article is missing an important bit of information - you need to configure the provider and assign a connection string through web.config.

    <telerik.web.ui>
      <radScheduler defaultAppointmentProvider="Integrated">
        <appointmentProviders>
          <add name="SchedulerData" type="Telerik.Web.Examples.Scheduler.MyDbSchedulerProvider" connectionStringName="TelerikConnectionString" persistChanges="true"/>
        </appointmentProviders>
      </radScheduler>
    </telerik.web.ui>

    More information on how to configure the provider is available here:
    http://www.telerik.com/help/aspnet-ajax/schedule_databindingusingadataprovider.html

    With the configuration in place you should no longer receive the error messages.

    Regards,
    Tsvetomir Tsonev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 06 Jan 2010 Link to this post

    Thanks for getting me one step closer to the solution :)

    I included the provider in my web.config as follows:
    <telerik.web.ui> 
      <radScheduler defaultAppointmentProvider="Integrated"
        <appointmentProviders> 
          <add name="SchedulerData" type="Colleague" connectionStringName="MyConnectionString" persistChanges="true"/> 
        </appointmentProviders> 
      </radScheduler> 
    </telerik.web.ui> 


    The type is set equal to my Colleague-class (the Colleagues.cs-file), and I re-edited it in order to use the original 
    using (DbConnection conn = OpenConnection())
    But, now the error returns once again ("System.NullReferenceException: Object reference  not set to an instance of an object").

    In my .aspx-file which includes the Scheduler I set the Scheduler's ProviderName="SchedulerData". (It still has an sql-datasource, set by DataSourceID="sqlAppointments", removing it did not change the outcome.)

    So, it seems the provider and its connection string did not do the trick. Or (and this is probably it), there is still some details which I have failed to include.
    Hoping for your guidance as always :)
  9. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 06 Jan 2010 Link to this post

    I just wanted to add that the functionality I need is covered in your example at:

    This, however uses an xml-source, and I need to use my sql-table. Also, I need some extra-functionality, e.g. only displaying available users when setting up appointments and updating the list of availables live when altering time and date inside the AdvancedInsert/EditForm.

    Also, I converted back to include my alteration of the OpenConnection, like this:
        protected override DbConnection OpenConnection() 
        { 
            SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["MyConnectionString"].ToString()); 
            conn.Open(); 
            return conn; 
        } 

    So, now it works, but the users are not generated.
    I really need this to function 100%, and I hope you might be able to present an example of the MultipleResourceValues-example with a dataprovider (sql) version.
  10. R
    R avatar
    14 posts
    Member since:
    Oct 2007

    Posted 06 Jan 2010 Link to this post

    One last update, before I continue my work for a 100% functioning Scheduler:
    The reason why the users wasn't generated was that I had forgot to declare the Type-parameter in the user control. By setting Type="Colleague" the users were visible. Perfect!

    Now, all I need is to figure out the correct insert, update, delete queries :)
  11. T. Tsonev
    Admin
    T. Tsonev avatar
    2815 posts

    Posted 13 Jan 2010 Link to this post

    Hello,

    Doing dynamic filtering of the available resources in the advanced form won't be very easy, but it's possible with customized template. More details on how to customize the advanced template here:
    http://demos.telerik.com/aspnet-ajax/scheduler/examples/advancedformtemplate/defaultcs.aspx

    Let us know if you have any outstanding issues with the provider.

    All the best,
    Tsvetomir Tsonev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. roshani
    roshani avatar
    45 posts
    Member since:
    Dec 2010

    Posted 05 Jan 2011 Link to this post

    Hello Admin,

    I am using the inbuilt AdvanceForm to insert/Edit the appointments. I have created a demo project same way which is working fine.
    But when I tried to use the same in the real appilication, it is giving error. I haven't customized it. Appointments doesn't get inserted as all the fields Subject, Start, End, etc. returns null.
    Here is the code.

     

     

    <asp:SqlDataSource ID="SDSAppointments" runat="server" ConnectionString="<%$ appSettings:DBConn %>"

     

     

     

    SelectCommand="SELECT [AppointmentId], [Subject], [Start], [End], [LessonTypeId], [InstructorId], [CustomerId], [RecurrenceRule], [RecurenceParentId], [Description], [IsInactive], [IsDelivered], [IsEdited], [IsDeleted], [FlightHours], [GroundHours], [Comments] FROM [Appointment] WHERE ([IsDeleted] = 0) And (InstructorId = @instructorId)" ProviderName="System.Data.SqlClient"
    InsertCommand="INSERT INTO Appointment([Subject], [Start], [End], [LessonTypeId], [InstructorId], [CustomerId], [RecurrenceRule], [RecurenceParentId], [Description],[IsInactive],[IsDelivered], [IsEdited],[IsDeleted], [FlightHours], [GroundHours], [Comments]) VALUES (@Subject, @Start, @End, @LessonTypeId, @InstructorId, @CustomerId, @RecurrenceRule, @RecurenceParentId, @Description, @IsInactive, @IsDelivered, @IsEdited, @IsDeleted, @FlightHours, @GroundHours, @Comments)" >
    <SelectParameters>
    <asp:ControlParameter ControlID="HDNInstructorId" DefaultValue="0" Name="instructorId" PropertyName="Value" /> </SelectParameters>
    <InsertParameters>
    <asp:Parameter Name="Subject" DbType="String" />
    <asp:Parameter Name="Start" DbType="DateTime" />
    <asp:Parameter Name="End" DbType="DateTime" />
    <asp:Parameter Name="LessonTypeId" DbType="Int32" />
    <asp:Parameter Name="InstructorId" DbType="Int32"/>
    <asp:Parameter Name="CustomerId" DbType="Int32" />
    <asp:Parameter Name="RecurrenceRule" DbType="String"/>
    <asp:Parameter Name="RecurenceParentId" DbType="String" />
    <asp:Parameter Name="Description" DbType="String" />
    <asp:Parameter Name="IsInactive" DbType="Int16"/>
    <asp:Parameter Name="IsDelivered" DbType="Int16" />
    <asp:Parameter Name="IsEdited" DbType="Int16"/>
    <asp:Parameter Name="IsDeleted" DbType="Int16" />
    <asp:Parameter Name="FlightHours" DbType="Int16"/>
    <asp:Parameter Name="GroundHours" DbType="Int16" />
    <asp:Parameter Name="Comments" DbType="Int16"/>
    </InsertParameters></asp:SqlDataSource>
    <asp:SqlDataSource ID="SDSStudents" runat="server" ConnectionString="<%$ appSettings:DBConn %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT DISTINCT InS.StudentID, C.FirstName + ' ' + C.LastName AS StudentName FROM InstructorStudents AS InS INNER JOIN Customer AS C ON InS.StudentID = C.CustomerID WHERE (InS.InstructorId = @instructorId)">
    <SelectParameters>
    <asp:ControlParameter ControlID="HDNInstructorId" DefaultValue="0" Name="instructorId" PropertyName="Value" />
    </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SDSLessonType" runat="server" ConnectionString="<%$ appSettings:DBConn %>"
    ProviderName="System.Data.SqlClient" SelectCommand="Select Top 7 [CategoryID] ,[Name] from Category Where [ParentCategoryID]=0"></asp:SqlDataSource>
    <div>
    <asp:HiddenField ID="HDNInstructorId" runat="server" />
    <telerik:RadScheduler ID="RadScheduler1" runat="server" DataSourceID="SDSAppointments" AllowDelete="False" EnableDescriptionField="True" Height="500px" Width="650px" Skin="Telerik" SelectedView="WeekView" EnableReminderField="False" RecurrenceChoiceDialogDefaultRecurrenceMode="Series" ShowsConfirmationWindowOnDelete="True" DataEndField="End" DataDescriptionField="Description" DataKeyField="AppointmentId" DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurenceParentId"
    DataStartField="Start" DataSubjectField="Subject" onappointmentinsert="RadScheduler1_AppointmentInsert" CustomAttributeNames="FlightHours,GroundHours,Comments" EnableCustomAttributeEditing="True">
    <AdvancedForm Modal="true" EnableCustomAttributeEditing="True" />
    <ResourceTypes>
    <telerik:ResourceType DataSourceID="SDSStudents" ForeignKeyField="CustomerId" KeyField="StudentID" Name="Students" TextField="StudentName" />
    <telerik:ResourceType DataSourceID="SDSLessonType" ForeignKeyField="LessonTypeId" KeyField="CategoryID" ame="LessonType" TextField="Name" />
    </ResourceTypes>
    </telerik:RadScheduler>


    Please reply as soon as possible.
    Its Urgent..

    thanks,
    Roshani

     

  13. roshani
    roshani avatar
    45 posts
    Member since:
    Dec 2010

    Posted 05 Jan 2011 Link to this post

    I am using the latest trial version. Though it is not working.
    Please reply soon.
  14. roshani
    roshani avatar
    45 posts
    Member since:
    Dec 2010

    Posted 05 Jan 2011 Link to this post

    I have also tried the Foolowing Method

    SDSAppointments.InsertParameters[

     

    "Subject"].DefaultValue = e.Appointment.Subject.ToString();

     

    SDSAppointments.InsertParameters[

     

    "Start"].DefaultValue = e.Appointment.Start.ToString();

     

    SDSAppointments.InsertParameters[

     

    "End"].DefaultValue = e.Appointment.End.ToString();

     

     

     

    //SDSAppointments.InsertParameters["LessonTypeId"].DefaultValue = e.Appointment.Resources.GetResourceByType("LessonType").ToString();

     

    SDSAppointments.InsertParameters[

     

    "InstructorId"].DefaultValue=HDNInstructorId.Value;

     

     

     

    //SDSAppointments.InsertParameters["CustomerId"].DefaultValue=e.Appointment.Attributes["CustomerId"].ToString();

     

    SDSAppointments.InsertParameters[

     

    "RecurrenceRule"].DefaultValue=e.Appointment.RecurrenceRule.ToString();

     

    SDSAppointments.InsertParameters[

     

    "RecurenceParentId"].DefaultValue=e.Appointment.RecurrenceParentID.ToString();

     

    SDSAppointments.InsertParameters[

     

    "Description"].DefaultValue = e.Appointment.Description.ToString();

     

    SDSAppointments.InsertParameters[

     

    "IsInactive"].DefaultValue = "0";

     

    SDSAppointments.InsertParameters[

     

    "IsDelivered"].DefaultValue = "0";

     

    SDSAppointments.InsertParameters[

     

    "IsEdited"].DefaultValue = "0";

     

    SDSAppointments.InsertParameters[

     

    "IsDeleted"].DefaultValue = "0";

     

    SDSAppointments.InsertParameters[

     

    "FlightHours"].DefaultValue =e.Appointment.Attributes["FlightHours"].ToString();

     

    SDSAppointments.InsertParameters[

     

    "GroundHours"].DefaultValue =e.Appointment.Attributes["FlightHours"].ToString();

     

    SDSAppointments.InsertParameters[

     

    "Comments"].DefaultValue = e.Appointment.Attributes["FlightHours"].ToString();

    Here it is giving error for the other values that need to be stored.

     

  15. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 06 Jan 2011 Link to this post

    Hi R,

    We will be glad to help you, but we will need a working demo of the problem. This seems an issue with the data source you use to bind RadScheduler. To attach files, please open a support ticket and we will get back to you as soon as possible.


    Best wishes,
    Peter
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  16. roshani
    roshani avatar
    45 posts
    Member since:
    Dec 2010

    Posted 06 Jan 2011 Link to this post

    Hello Admin,

    I have developed demo project which is working fine with smilar type of scenario. Now I am implementing the same thing with little changes in database. I have used sqldatasource control with the radscheduler. RadScheduler displys appointmnets also updates the IsDeleted field OnAppointmentDelete Event. I am just unable to Insert the appointment. I cann't provide the code as it is a hige application. So giving some more details here. I haven't customized the advancedForm. Code is already there in the above posts. Database Structure is as follows:
    Appointment table fields and description
    AppointmentId
    Subject
    Start
    End
    lessonTypeId
    InstructorId
    CustomerId
    RecurrenceRule
    RecurenceParentId
    Description
    IsInactive
    IsDelivered
    IsEdited
    IsDeleted
    FlightHours
    GroundHours
    Comments


    ApplicationInfo Class
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Web.UI;
    public class AppointmentInfo
    {
    #region "Private Variables"
    private readonly string _id;
    private string _Subject;
    private DateTime _Start;
    private DateTime _End;
    private string _RecurrenceRule;
    private string _RecurrenceParentId;
    private Int32 _InstructorId;
    private Int32 _CustomerId;
    private Int32 _LessonTypeId;
    private string _Description;
    private int _IsDeleted;
    private int _IsInactive;
    private int _IsDelivered;
    private int _IsEdited;
    private Decimal _FlightHours;
    private Decimal _GroundHours;
    private string _Comments;
    #endregion
    #region "Properties"
    public string Id
    {
    get { return _id; }
    }
    public string Subject
    {
    get { return _Subject; }
    set { _Subject = value; }
    }
    public DateTime Start
    {
    get { return _Start; }
    set { _Start = value; }
    }
    public DateTime End
    {
    get { return _End; }
    set { _End = value; }
    }
    public string RecurrenceRule
    {
    get { return _RecurrenceRule; }
    set { _RecurrenceRule = value; }
    }
    public string RecurrenceParentId
    {
    get { return _RecurrenceParentId; }
    set { _RecurrenceParentId = value; }
    }
    public Int32 InstructorId
    {
    get { return _InstructorId; }
    set { _InstructorId = value; }
    }
    public Int32 CustomerId
    {
    get { return _CustomerId; }
    set { _CustomerId = value; }
    }
    public Int32 LessonTypeId
    {
    get { return _LessonTypeId; }
    set { _LessonTypeId = value; }
    }
    public string Description
    {
    get { return _Description; }
    set { _Description = value; }
    }
    public int IsDeleted
    {
    get { return _IsDeleted; }
    set { _IsDeleted = value; }
    }
    public int IsInactive
    {
    get { return _IsInactive; }
    set { _IsInactive = value; }
    }
    public int IsDelivered
    {
    get { return _IsDelivered; }
    set { _IsDelivered = value; }
    }
    public int IsEdited
    {
    get { return _IsEdited; }
    set { _IsEdited = value; }
    }
    public Decimal FlightHours
    {
    get { return _FlightHours; }
    set { _FlightHours = value; }
    }
    public Decimal GroundHours
    {
    get { return _GroundHours; }
    set { _GroundHours = value; }
    }
    public string Comments
    {
    get { return _Comments; }
    set { _Comments = value; }
    }
    #endregion
    private AppointmentInfo()
    {
    _id = Guid.NewGuid().ToString();
    }
    public AppointmentInfo(string subject, DateTime start, DateTime end, Int32 lessonTypeId, Int32 instructorId,
    Int32 customerId, string recurrenceRule, string recurrenceParentID, string description, int isInactive,
    int isDelivered, int isEdited, int isDeleted, decimal flightHours, decimal groundHours, string comments)
    :
    this()
    {
    _Subject = subject;
    _Start = start;
    _End = end;
    _LessonTypeId = lessonTypeId;
    _InstructorId = instructorId;
    _CustomerId = customerId;
    _RecurrenceRule = recurrenceRule;
    _RecurrenceParentId = recurrenceParentID;
    _Description = description;
    _IsInactive = isInactive;
    _IsDelivered = isDelivered;
    _IsEdited = isEdited;
    _IsDeleted = isDeleted;
    _FlightHours = flightHours;
    _GroundHours = groundHours;
    _Comments = comments;
    }
    public AppointmentInfo(Appointment source): this()
    {CopyInfo(source);}
    public void CopyInfo(Appointment source)
    {
    Subject = source.Subject;
    Start = source.Start;
    End = source.End;
    RecurrenceRule = source.RecurrenceRule;
    if (source.RecurrenceParentID != null)
    {
    RecurrenceParentId = source.RecurrenceParentID.ToString();
    }
    CustomerId =
    Convert.ToInt32(source.Attributes["CustomerId"].ToString());
    InstructorId =
    Convert.ToInt32(source.Attributes["InstructorId"].ToString());
    LessonTypeId =
    Convert.ToInt32(source.Attributes["LessonTypeId"].ToString());
    Description = source.Description;
    IsDeleted =
    Convert.ToInt32(source.Attributes["IsDeleted"].ToString());
    IsInactive =
    Convert.ToInt32(source.Attributes["IsDeleted"].ToString());
    IsDelivered =
    Convert.ToInt32(source.Attributes["IsDelivered"].ToString());
    IsEdited =
    Convert.ToInt32(source.Attributes["IsEdited"].ToString());
    FlightHours =
    Convert.ToDecimal(source.Attributes["FlightHours"].ToString());
    GroundHours =
    Convert.ToDecimal(source.Attributes["GroundHours"].ToString());
    Comments = source.Attributes[
    "GroundHours"].ToString();
    }
    }

    When I click on the "Save"  button the form didn't get close. When I searched for the error "Insert Error. Connot insert null value in the column Subject." Same thing happens with all other fields.
    Please reply as soon as possible.
  17. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 07 Jan 2011 Link to this post

    Hello R,

    Please, send us also your RadScheduler declaration and how you handle its AppointmentInsert/Delete/Updated events.


    Kind regards,
    Peter
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  18. roshani
    roshani avatar
    45 posts
    Member since:
    Dec 2010

    Posted 09 Jan 2011 Link to this post

    Hello Admin,



    Thanks for replying,
    The problem has been solved. Still I don't know the reason.  By the way I have already attached it. you can found it in one of the above posts.


  19. Ramya
    Ramya avatar
    4 posts
    Member since:
    Oct 2012

    Posted 12 Sep 2012 Link to this post

    Hi,
    Iam using rad scheduler in one of my projects. I am using advancedinsert template and a user control in the insert template. When i save the event on clicking save button from user control , event gets added to database but i get an exception
    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Web.UI.RadScheduler.InsertAppointmentInline() +79
       Telerik.Web.UI.RadScheduler.OnBubbleEvent(Object source, EventArgs args) +483
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
    

    The rad scheduler is as below
    <telerik:RadScheduler runat="server" ID="RegScheduler" CssClass="RegScheduler"
                SelectedView="MonthView" AllowDelete="false" AppointmentStyleMode="Default"
                TimelineView-UserSelectable="false" CustomAttributeNames="EventStatus"
                  StartInsertingInAdvancedForm="True"     
                EnableCustomAttributeEditing="True"  EnableExactTimeRendering="True"  StartEditingInAdvancedForm="true"
                EnableResourceEditing="False"   AdvancedForm-EnableCustomAttributeEditing="True"  
                OnClientAppointmentsPopulating="appointmentsPopulating" OnClientAppointmentsPopulated="appointmentsPopulated"           
                OnClientDataBound="clientDataBound"
                AllowEdit='<%# AllowCalendarEventEditing %>'   
                AllowInsert='<%# AllowCalendarEventEditing %>'>
                <AdvancedForm Modal="true" />          
                <WebServiceSettings Path="Controls/Registration/Calendar/SchedulerWcfService.svc" />
                <AdvancedEditTemplate>
                <uc2:ManageEvent runat="server" ID="AdvancedEditForm1" Mode="Edit" SelectedCompanies='<%# SelectedCompanies %>' CalendarMode='<%# CalendarMode %>' CurrentTimeZone='<%# CurrentTimeZone %>' />
                </AdvancedEditTemplate>

                <AdvancedInsertTemplate>
                 <uc2:ManageEvent runat="server"  ID="AdvancedInsertForm1" Mode="Insert" SelectedCompanies='<%# SelectedCompanies %>' CalendarMode='<%# CalendarMode %>' CurrentTimeZone='<%# CurrentTimeZone %>' StartDateTime='<%# Bind("Start") %>' EndDateTime='<%# Bind("End") %>' />
                </AdvancedInsertTemplate>

    But when i reload the calendar i see the event added. can you please advice on what to look at?
    How can i avoid the exception?

    Thanks
    Ramya
  20. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 13 Sep 2012 Link to this post

    Hello Ramya,

    I have answered to your request in the other forum thread you have opened on this subject. I recommend to continue our conversation in one thread so possible misunderstanding could be avoided.

    Kind regards,
    Ivana
    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