I am trying to connect RadCalender with sql data source, but I can not modify the data I created, it always gives me error msg
System.NullReferenceException: Object reference not set to an instance of an object.
I can't delete anything or input anything either through the schedule.
I set up all the property like the sample set up, anyone else met this problem before?
System.NullReferenceException: Object reference not set to an instance of an object.
|
I can't delete anything or input anything either through the schedule.
I set up all the property like the sample set up, anyone else met this problem before?
4 Answers, 1 is accepted
0
Hello Peter,
We will be happy to help you but we will need additional information on how you implement this and the exact steps to reproduce the problem. Ideally, you can open a support ticket and send us a demo project which we can test locally.
Greetings,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
We will be happy to help you but we will need additional information on how you implement this and the exact steps to reproduce the problem. Ideally, you can open a support ticket and send us a demo project which we can test locally.
Greetings,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Nyceane
Top achievements
Rank 1
answered on 19 Nov 2007, 07:17 PM
hey Peter,
Server Error in '/Mitochon' Application.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Stack Trace:
Problem started as I am trying to duplicate Resource Availability Page that you've listed under Demo. Below is my exact coding, I don't know how to send you a demo of the project but the coding is almost identical to the demo you have on the web site.
for ASP.NET
<%@ Page Language="C#" MasterPageFile="~/Mitochon.master" AutoEventWireup="true" CodeFile="Schedule.aspx.cs" Inherits="Telerik.Schedule.Databind.ScheduleSource" Title="Untitled Page" %> |
<%@ Register Assembly="SessionDataSource" Namespace="SessionDS" TagPrefix="cc1" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> |
<div class="title"> |
Available employees: <asp:Label runat="server" ID="AvailableUsers" /> |
<br/> |
Available conference rooms: <asp:Label runat="server" ID="AvailableRooms" /> |
</div> |
<telerik:RadScheduler ID="RadScheduler1" runat="server" AllowDelete="True" AllowEdit="True" |
AllowInsert="True" DataSourceID="SqlDataSource1" HoursPanelTimeFormat="h:mm tt" |
SelectedDate="2007-11-16" DataEndField="EndTime" DataKeyField="ScheduleID" DataRecurrenceField="RecurrenceRule" |
DataRecurrenceParentKeyField="RecurrenceID" DataStartField="StartTime" DataSubjectField="Subject" |
OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" |
OnAppointmentInsert="RadScheduler1_AppointmentInsert" |
OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" |
OnAppointmentDelete="RadScheduler1_AppointmentDelete" |
OnDataBound="RadScheduler1_DataBound" |
OnAppointmentCreated="RadScheduler1_AppointmentCreated"> |
<AppointmentTemplate> |
<%# Eval("Subject") %> |
<br /> |
<asp:Label runat="server" ID="AssignedTo" /> |
<br /> |
<asp:Label runat="server" ID="Location" /> |
</AppointmentTemplate> |
<ResourceTypes> |
<telerik:ResourceType DataSourceID="RoomsDataSource" ForeignKeyField="LocationID" |
KeyField="ID" Name="Location" TextField="RoomName" /> |
<telerik:ResourceType DataSourceID="UserDataSource" ForeignKeyField="UserID" KeyField="ID" |
Name="User" TextField="UserName" /> |
</ResourceTypes> |
</telerik:RadScheduler> |
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:992740df-ebac-4409-854a-0a16637c8b00ConnectionString1 %>" |
ProviderName="<%$ ConnectionStrings:992740df-ebac-4409-854a-0a16637c8b00ConnectionString1.ProviderName %>" |
SelectCommand="SELECT * FROM System.[Schedule]" |
DeleteCommand="DELETE FROM System.[Schedule] WHERE ScheduleID = @ScheduleID" |
InsertCommand="INSERT INTO System.[Schedule] ([Subject],[StartTime], [EndTime], [LocationID], [UserID], [RecurrenceRule], [RecurrenceID]) VALUES (@Subject,@StartTime, @EndTime, @LocationID, @UserID, @RecurrenceRule, @RecurrenceID)" |
UpdateCommand="UPDATE System.[Schedule] SET [Subject]=@Subject, [StartTime]=@StartTime, [EndTime]=@EndTime, [RecurrenceRule]=@RecurrenceRule, [LocationID] = @LocationID, [UserID] = @UserID, [RecurrenceID]=@RecurrenceID WHERE (ScheduleID=@ScheduleID)"> |
<DeleteParameters> |
<asp:Parameter Name="ScheduleID" /> |
</DeleteParameters> |
<UpdateParameters> |
<asp:Parameter Name="Subject" /> |
<asp:Parameter Name="StartTime" /> |
<asp:Parameter Name="EndTime" /> |
<asp:Parameter Name="LocationID" /> |
<asp:Parameter Name="UserID" /> |
<asp:Parameter Name="RecurrenceRule" /> |
<asp:Parameter Name="RecurrenceID" /> |
<asp:Parameter Name="ScheduleID" /> |
</UpdateParameters> |
<InsertParameters> |
<asp:Parameter Name="Subject" /> |
<asp:Parameter Name="StartTime" /> |
<asp:Parameter Name="EndTime" /> |
<asp:Parameter Name="LocationID" /> |
<asp:Parameter Name="UserID" /> |
<asp:Parameter Name="RecurrenceRule" /> |
<asp:Parameter Name="RecurrenceID" /> |
</InsertParameters> |
</asp:SqlDataSource> |
<asp:SqlDataSource ID="RoomsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SchedulerDataConnectionString1 %>" |
ProviderName="<%$ ConnectionStrings:SchedulerDataConnectionString1.ProviderName %>" |
SelectCommand="SELECT * FROM [Rooms]"> |
</asp:SqlDataSource> |
<asp:SqlDataSource ID="UserDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SchedulerDataConnectionString1 %>" |
ProviderName="<%$ ConnectionStrings:SchedulerDataConnectionString1.ProviderName %>" |
SelectCommand="SELECT [ID], [UserName] FROM [Users]"> |
</asp:SqlDataSource> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
</asp:Content> |
|
and for C# code behind it is copied word by word
using System; |
using System.Data; |
using System.Configuration; |
using System.Collections; |
using System.Collections.Generic; |
using System.Drawing; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Web.UI.HtmlControls; |
using Telerik.Web.UI; |
using Telerik.QuickStart; |
namespace Telerik.Schedule.Databind |
{ |
public partial class ScheduleSource : XhtmlPage |
{ |
private const string UsedResourcesSessionKey = "Telerik.Schedule.Databind.ScheduleSource"; |
private List<Resource> UsedResources |
{ |
get |
{ |
List<Resource> resources = Session[UsedResourcesSessionKey] as List<Resource>; |
if (resources == null) |
{ |
resources = new List<Resource>(); |
Session[UsedResourcesSessionKey] = resources; |
} |
return resources; |
} |
} |
private void Page_Load(object sender, EventArgs e) |
{ |
if (!IsPostBack) |
{ |
UsedResources.Clear(); |
} |
} |
private void ReserveResources(ResourceCollection resources) |
{ |
foreach (Resource res in resources) |
{ |
if (!UsedResources.Contains(res)) |
{ |
UsedResources.Add(res); |
} |
} |
} |
private void FreeResources(ResourceCollection resources) |
{ |
foreach (Resource res in resources) |
{ |
if (UsedResources.Contains(res)) |
{ |
UsedResources.Remove(res); |
} |
} |
} |
protected void RadScheduler1_DataBound(object sender, EventArgs e) |
{ |
foreach (Resource res in RadScheduler1.Resources) |
{ |
res.Available = !UsedResources.Contains(res); |
} |
DisplayAvailableResources(); |
} |
protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e) |
{ |
ReserveResources(e.Appointment.Resources); |
} |
protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e) |
{ |
ReserveResources(e.Appointment.Resources); |
} |
protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) |
{ |
FreeResources(e.Appointment.Resources); |
ReserveResources(e.ModifiedAppointment.Resources); |
} |
protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e) |
{ |
FreeResources(e.Appointment.Resources); |
} |
protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e) |
{ |
List<string> users = new List<string>(); |
foreach (Resource user in e.Appointment.Resources.GetResourcesByType("User")) |
{ |
users.Add(user.Text); |
} |
Label assignedTo = (Label)e.Container.FindControl("AssignedTo"); |
if (users.Count > 0) |
{ |
assignedTo.Text = "Assigned to: " + string.Join(", ", users.ToArray()); |
} |
else |
{ |
assignedTo.Text = "Not assigned."; |
} |
Resource room = e.Appointment.Resources.GetResourceByType("Room"); |
if (room != null) |
{ |
Label location = (Label)e.Container.FindControl("Location"); |
location.Text = "Location: " + room.Text; |
} |
} |
private void DisplayAvailableResources() |
{ |
List<string> users = new List<string>(); |
foreach (Resource user in RadScheduler1.Resources.GetResourcesByType("User")) |
{ |
if (user.Available) |
{ |
users.Add(user.Text); |
} |
} |
AvailableUsers.Text = string.Join(", ", users.ToArray()); |
List<string> rooms = new List<string>(); |
foreach (Resource room in RadScheduler1.Resources.GetResourcesByType("Room")) |
{ |
if (room.Available) |
{ |
rooms.Add(room.Text); |
} |
} |
AvailableRooms.Text = string.Join(", ", rooms.ToArray()); |
} |
} |
} |
I don't know why its keep giving me message
Server Error in '/Mitochon' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
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:
|
when I am copying the exact same project, the only difference is that I am using SQL datasource rather than session datasource.
0

Nyceane
Top achievements
Rank 1
answered on 19 Nov 2007, 08:57 PM
Peter, I've redone the entire project again, it appears that schedule will only work with SQL database when there is no master page present, and whenever the scheduler works under a master page, the same error pops up
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Have anyone else ever encountered such problem?
0
Hello Peter,
Thank you for your continuous involvement and feedback.
I did a test project based on your description, which runs as a stand-alone application, but everything worked as expected. Please, refer to the attached project and check what is different with your application.
All the best,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for your continuous involvement and feedback.
I did a test project based on your description, which runs as a stand-alone application, but everything worked as expected. Please, refer to the attached project and check what is different with your application.
All the best,
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center