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

Custom Attributes

5 Answers 179 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Hans Jørgen
Top achievements
Rank 1
Hans Jørgen asked on 21 Jul 2008, 03:50 PM
Hi
I have a small problem in my scheduler.

When I use a parameter to get an selected user when loading scheduler with the following code

MyPage

page1 = (MyPage) owner.Page;
string param1 = page1.MyParam;

and use the folling code in my .aspx file

<telerik:RadScheduler ID="RadScheduler1" runat="server" DataEndField="Slut" DataKeyField="ID" LastDayOfWeek="Sunday" ProviderName="SchedulerData" Culture="Danish (Denmark)" FirstDayOfWeek="Monday" Skin="Outlook" DataRecurrenceField="Gentagelse" DataRecurrenceParentKeyField="GentagelseID" DataSourceID="SqlDataSource1" DataStartField="Start" DataSubjectField="Emne" CustomAttributeNames="Kommentar" EnableCustomAttributeEditing="True">
<AppointmentTemplate>
<%# Eval("Subject") %>
<%
# Eval("Kommentar").ToString() != String.Empty ? "[" + Eval("Kommentar") + "]" : String.Empty %>
</AppointmentTemplate>
<MonthView HeaderDateFormat="MMMM yyyy" />
<DayView HeaderDateFormat="dddd dd MMMM yyyy" />
<WeekView ColumnHeaderDateFormat="ddd, d" />
</telerik:RadScheduler>

 I get the following error 

System.NullReferenceException: Object reference not set to an instance of an object.

But when I use your example Defining Resources I get no error.
this code looks like this

<telerik:RadScheduler ID="RadScheduler1" runat="server" Width="569px" Skin="Outlook" Culture="Danish (Denmark)" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" DataEndField="Slut" DataKeyField="ID" DataRecurrenceField="Gentagelse" DataRecurrenceParentKeyField="GentagelseID" DataSourceID="AppointmentsDataSource" DataStartField="Start" DataSubjectField="Emne" OnAppointmentCreated="RadScheduler1_AppointmentCreated" EnableCustomAttributeEditing="True" CustomAttributeNames="Kommentar">
<ResourceTypes>
<telerik:ResourceType KeyField="UserID" Name="Bruger" TextField="UserName" ForeignKeyField="BrugerID" DataSourceID="UsersDataSource" />
</ResourceTypes>
<AppointmentTemplate>
<%# Eval("Subject") %>
<%
# Eval("Kommentar").ToString() != String.Empty ? "[" + Eval("Kommentar") + "]" : String.Empty %>
</AppointmentTemplate>
<MonthView HeaderDateFormat="MMMM yyyy" />
<DayView HeaderDateFormat="dddd d MMMM yyyy" />
<WeekView ColumnHeaderDateFormat="ddd d" />
</telerik:RadScheduler>

Why that.
Should I get all users to get work?

Hope you can help me.

Best regards
Hans Jørgen

5 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 22 Jul 2008, 12:54 PM
Hi Hans,

The call stack should note where the error comes from. Can you post it?

Additionally, you can attach the VS debugger and check the place where the exception is thrown. This should shed some more light to the source of the problem.

If that does not help, is it possible for you to open a formal support ticket and send us the project? Please, add a simplified version of the database if not local.

Regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 22 Jul 2008, 05:12 PM
Hi
Here is my stack trace of my problem.

[NullReferenceException: Object reference not set to an instance of an object.]
   ASP.admin_brugerfiler_kalender_aspx.__DataBind__control3(Object sender, EventArgs e) in n:\Safe-and-secure\Admin\Brugerfiler\Kalender.aspx:23
   System.Web.UI.Control.OnDataBinding(EventArgs e) +99
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +206
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +204
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +204
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +204
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +204
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +204
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   Telerik.Web.UI.RadScheduler.CreateChildControls(Boolean bindFromDataSource) +423
   Telerik.Web.UI.RadScheduler.CreateChildControls() +10
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +50
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041


I hope thats enough to find the problem

Thank you very much

Best regards
HansJørgen
0
T. Tsonev
Telerik team
answered on 23 Jul 2008, 12:54 PM
Hello Hans,

My guess is that in some of the database records the "Kommentar" field is NULL. In this case "Eval("Kommentar").ToString()" will throw this exception.

I cannot be completely sure about this by looking at this code snippet alone. So, if this is not the problem, can you please send as a runnable page that we can test with?

Best wishes,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hans Jørgen
Top achievements
Rank 1
answered on 28 Jul 2008, 05:25 PM
Hi again

Yes some of the fields are empty, but why can I use the function when I get all users as an admin and not when I use parameter to get a single user.

How can I send the files to you so you can test the problems?

Have a nice day.

Best regards
Hans Jørgen
0
Atanas Korchev
Telerik team
answered on 29 Jul 2008, 08:06 AM
Hi Hans Jørgen,

You should open a support ticket in order to attach a file.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
Hans Jørgen
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
Hans Jørgen
Top achievements
Rank 1
T. Tsonev
Telerik team
Atanas Korchev
Telerik team
Share this question
or