Hello,
I am currently testing out the RADcontrols and specificaly the scheduler at the moment.
I always much rather set my datasources in the code-behind and tried so.
This is what my front code looks like:
and here is my code-behind:
It uses the template from the example shown here:
http://www.telerik.com/demos/aspnet/prometheus/Scheduler/Examples/ResourceGrouping/DefaultCS.aspx
Now I also added the SessionDataSource.cs in my app_code and I have no build errors. Still I am receiving an error in my SessionDataSource.cs:
Object not set to a reference of an object (I get the dutch version so sorry if my translation isn't 100% correct)
The error occurs on line:
in SessionDataSource.cs
Any idea what I am doing wrong?
Thanks in advance!
I am currently testing out the RADcontrols and specificaly the scheduler at the moment.
I always much rather set my datasources in the code-behind and tried so.
This is what my front code looks like:
<telerik:RadScheduler runat="server" ID="radAfspraken" |
Width="900px" Skin="Sunset" EnableEmbeddedSkins="True" SelectedView="DayView" GroupBy="Plaats" GroupingDirection="Horizontal" |
DayStartTime="08:00:00" DayEndTime="19:00:00" TimeZoneOffset="03:00:00" |
DataKeyField="ID" DataSubjectField="Omschrijving" |
DataStartField="Start" DataEndField="Eind" DataRecurrenceField="Herhalingsregel" |
DataRecurrenceParentKeyField="HerhalingsID"> |
<TimelineView UserSelectable="false" /> |
</telerik:RadScheduler> |
and here is my code-behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
Dim sdsA As SessionDataSource |
sdsA = New SessionDataSource |
sdsA.ID = "sdsAfspraak" |
sdsA.DisplayWarning = False |
sdsA.PrimaryKeyFields = "ID" |
sdsA.ProviderName = "System.Data.SqlClient" |
sdsA.ConnectionString = ConfigurationManager.ConnectionStrings("UrenPortal").ConnectionString |
sdsA.SelectCommand = "Select ID, omschrijving, start, eind, plaatsID, herhalingsregel, herhalingsID FROM afspraken" |
sdsA.InsertCommand = "INSERT INTO afspraken (omschrijving, start, eind, PlaatsID, herhalingsregel, herhalingsID) VALUES (@Omschrijving, @Start, @Eind, @PlaatsID, @Herhalingsregel, @HerhalingsID)" |
sdsA.UpdateCommand = "UPDATE afspraken SET omschrijving = @Omschrijving, start = @Start, eind = @Eind, PlaatsID = @PlaatsID, Herhalingsregel = @Herhalingsregel, HerhalingsID = @HerhalingsID WHERE ID = @ID" |
sdsA.DeleteCommand = "DELETE FROM afspraken WHERE ID = @ID" |
sdsA.DeleteParameters.Add(New Parameter("ID", TypeCode.Int32)) |
sdsA.UpdateParameters.Add(New Parameter("ID", TypeCode.Int32)) |
sdsA.UpdateParameters.Add(New Parameter("omschrijving", TypeCode.String)) |
sdsA.UpdateParameters.Add(New Parameter("start", TypeCode.DateTime)) |
sdsA.UpdateParameters.Add(New Parameter("eind", TypeCode.DateTime)) |
sdsA.UpdateParameters.Add(New Parameter("plaatsID", TypeCode.Int32)) |
sdsA.UpdateParameters.Add(New Parameter("herhalingsregel", TypeCode.String)) |
sdsA.UpdateParameters.Add(New Parameter("herhalingsID", TypeCode.Int32)) |
sdsA.InsertParameters.Add(New Parameter("omschrijving", TypeCode.String)) |
sdsA.InsertParameters.Add(New Parameter("start", TypeCode.DateTime)) |
sdsA.InsertParameters.Add(New Parameter("eind", TypeCode.DateTime)) |
sdsA.InsertParameters.Add(New Parameter("plaatsID", TypeCode.Int32)) |
sdsA.InsertParameters.Add(New Parameter("herhalingsregel", TypeCode.String)) |
sdsA.InsertParameters.Add(New Parameter("herhalingsID", TypeCode.Int32)) |
radAfspraken.DataSource = sdsA |
Dim sdsP As SessionDataSource |
sdsP = New SessionDataSource |
sdsP.ID = "sdsPlaats" |
sdsP.DisplayWarning = False |
sdsP.ConnectionString = ConfigurationManager.ConnectionStrings("UrenPortal").ConnectionString |
sdsP.ProviderName = "System.Data.SqlClient" |
sdsP.SelectCommand = "SELECT PlaatsID, Naam FROM plaatsen" |
Dim rtPlaats As New ResourceType |
rtPlaats.KeyField = "PlaatsID" |
rtPlaats.Name = "Plaats" |
rtPlaats.TextField = "Naam" |
rtPlaats.ForeignKeyField = "PlaatsID" |
rtPlaats.DataSource = sdsP |
radAfspraken.ResourceTypes.Add(rtPlaats) |
End Sub |
It uses the template from the example shown here:
http://www.telerik.com/demos/aspnet/prometheus/Scheduler/Examples/ResourceGrouping/DefaultCS.aspx
Now I also added the SessionDataSource.cs in my app_code and I have no build errors. Still I am receiving an error in my SessionDataSource.cs:
Object not set to a reference of an object (I get the dutch version so sorry if my translation isn't 100% correct)
The error occurs on line:
181: return (string) ViewState["SessionKey"] ?? Page.ToString() + "_" + ID; |
in SessionDataSource.cs
Any idea what I am doing wrong?
Thanks in advance!