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

RadScheduler ObjectDataSource operation

8 Answers 116 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Danilo
Top achievements
Rank 1
Danilo asked on 13 Jan 2011, 04:24 PM
Hi all,
Hi have a RadScheduler related to an objectdatasource. When i do some operation on the Scheduler, like Insert, Edit or Delete, I've notice that the scheduler exec the operation two time. The first time is executed from some "embedded" method and second time is execute from my method of the datasource. Why this happens? There is a way to disable the calling of the "embedded" method???
Thank's
Dan

8 Answers, 1 is accepted

Sort by
0
Accepted
Veronica
Telerik team
answered on 13 Jan 2011, 04:30 PM
Hi Danilo,

Could you please send me in a sample project what is this "embedded" method which is called before your method from the datasource? Meanwhile please take a look at our"Car Rental" application for an example of RadScheduler bound to ObjectDataSource.

All the best,
Veronica Milcheva
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.
0
Danilo
Top achievements
Rank 1
answered on 13 Jan 2011, 05:47 PM

 

This code execute the Insert, Delete, Update code two time.

This is the aspx page
-----------------------------------------------------------------------------------------


<
telerik:RadScheduler ID="RadScheduler1" runat="server"

 

 

AppointmentStyleMode="Default" DataEndField="DataFine" DataKeyField="ID"

 

 

DataRecurrenceField="RecurrenceRule"

 

 

DataRecurrenceParentKeyField="RecurrenceParentID"

 

 

DataSourceID="AppointmentsDataSource"

 

 

DataStartField="DataInizio"

 

 

DataSubjectField="Oggetto" DayEndTime="18:00:00" DayStartTime="08:00:00"

 

 

OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" Culture="IT-it"

 

 

TimeZoneOffset="03:00:00" Height="680px" OnClientAppointmentWebServiceDeleting=""

 

 

Localization-HeaderToday="Oggi" Localization-HeaderMonth="Mese"

 

 

Localization-HeaderDay="Giorno" Localization-HeaderWeek="Settimana" Localization-HeaderTimeline="TimeLine" >

 

 

 

<AdvancedForm Modal="true" />

 

 

<WeekView HeaderDateFormat="d" />

 

 

<TimeSlotContextMenuSettings EnableDefault="true" />

 

 

<AppointmentContextMenuSettings EnableDefault="true" />

 

 

</telerik:RadScheduler>

 

 

 

<asp:ObjectDataSource ID="AppointmentsDataSource" runat="server"

 

 

TypeName="AppointmentsProvider" OldValuesParameterFormatString="original_{0}"

 

 

SelectMethod="GetAppointments" DataObjectTypeName="AppointmentItem"

 

 

DeleteMethod="DeleteAppointment" InsertMethod="InsertAppointment"

 

 

UpdateMethod="UpdateAppointment">

 

 

</asp:ObjectDataSource>

This is the aspx.vb
-----------------------------------------------------------------------------------------

 

Partial

 

Class test_test_scheduler

 

 

Inherits System.Web.UI.Page

 

 

Protected Sub RadScheduler1_AppointmentDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerEventArgs) Handles RadScheduler1.AppointmentDataBound

 

 

 

 

End Sub

 

 

 

 

 

Protected Sub RadScheduler1_AppointmentDelete(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentDeleteEventArgs) Handles RadScheduler1.AppointmentDelete

 

e.Appointment.Attributes(

"UserID") = 1

 

 

End Sub

 

 

 

 

 

Protected Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentInsertEventArgs) Handles RadScheduler1.AppointmentInsert

 

 

 

 

e.Appointment.Attributes(

"UserID") = 2

 

 

End Sub

 

 

 

 

 

Protected Sub RadScheduler1_AppointmentUpdate(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentUpdateEventArgs) Handles RadScheduler1.AppointmentUpdate

 

e.Appointment.Attributes(

"UserID") = 3

 

 

End Sub

 

End

 

Class

 

 

 



This is the provider
-----------------------------------------------------------------------------------------


 

Imports

 

System.Collections.Generic

 

 

 

Imports

 

System.Data

 

 

 

Imports

 

MySql.Data.MySqlClient

 

 

 

Imports

 

System.Configuration

 

 

 

Imports

 

System.ComponentModel

 

<DataObject(

True)> _

 

 

 

Public

 

Class AppointmentsProvider

 

 

Private Shared Function GetConnectionString() As String

 

 

 

 

 

Return ConfigurationManager.ConnectionStrings("telerikConnectionString").ConnectionString

 

 

End Function

 

 

 

 

<DataObjectMethod(DataObjectMethodType.Select)> _

 

Public Shared Function GetAppointments() As List(Of AppointmentItem)

 

 

Dim cmd As New MySqlCommand("select * from appointments", New MySqlConnection(GetConnectionString()))

 

cmd.CommandType = CommandType.Text

 

 

 

 

cmd.Connection.Open()

 

 

Dim dr As MySqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

 

 

Dim appointmentList As New List(Of AppointmentItem)()

 

 

While dr.Read()

 

 

Dim appointment As New AppointmentItem()

 

appointment.ID = Convert.ToInt32(dr(

"ID"))

 

 

 

 

If Not dr("Subject") Is DBNull.Value Then

 

 

 

 

appointment.Oggetto = Convert.ToString(dr(

"Subject"))

 

 

End If

 

 

 

 

 

If Not dr("Start") Is DBNull.Value Then

 

 

 

 

appointment.DataInizio = Convert.ToDateTime(dr(

"Start"))

 

 

End If

 

 

 

 

 

If Not dr("End") Is DBNull.Value Then

 

 

 

 

appointment.DataFine = Convert.ToDateTime(dr(

"End"))

 

 

End If

 

 

 

 

 

If Not dr("UserID") Is DBNull.Value Then

 

 

 

 

appointment.UserID = Convert.ToInt32(dr(

"UserID"))

 

 

End If

 

 

 

 

 

If Not dr("RoomID") Is DBNull.Value Then

 

 

 

 

appointment.RoomID = Convert.ToInt32(dr(

"RoomID"))

 

 

End If

 

 

 

 

If Not dr("RecurrenceRule") Is DBNull.Value Then

 

 

 

 

appointment.RecurrenceRule = Convert.ToString(dr(

"RecurrenceRule"))

 

 

End If

 

 

 

 

 

If Not dr("RecurrenceParentID") Is DBNull.Value Then

 

 

 

 

appointment.RecurrenceParentID = Convert.ToInt32(dr(

"RecurrenceParentID"))

 

 

End If

 

 

 

 

 

If Not dr("Reminder") Is DBNull.Value Then

 

 

 

 

appointment.Reminder = Convert.ToString(dr(

"Reminder"))

 

 

End If

 

 

 

 

 

If Not dr("Annotations") Is DBNull.Value Then

 

 

 

 

appointment.Note = Convert.ToString(dr(

"Annotations"))

 

 

End If

 

 

 

 

 

If Not dr("Description") Is DBNull.Value Then

 

 

 

 

appointment.Descrizione = Convert.ToString(dr(

"Description"))

 

 

End If

 

 

 

 

appointmentList.Add(appointment)

 

End While

 

 

 

 

dr.Close()

 

Return appointmentList

 

 

End Function

 

 

 

 

<DataObjectMethod(DataObjectMethodType.Insert)> _

 

Public Shared Sub InsertAppointment(ByVal appointment As AppointmentItem)

 

 

 

 

Dim insertCommand As New StringBuilder

 

insertCommand.Append(

"INSERT INTO appointments" & vbCrLf)

 

insertCommand.Append(vbTab &

"(" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

"Subject" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", Start" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", End" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", UserID" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", RoomID" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", RecurrenceRule" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", RecurrenceParentID" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", Annotations" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", Description" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", Reminder" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", LastModified" & vbCrLf)

 

insertCommand.Append(vbTab &

")" & vbCrLf)

 

insertCommand.Append(

"VALUES")

 

insertCommand.Append(vbTab &

"(" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

"@Subject" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @Start" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @End" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @UserID" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @RoomID" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @RecurrenceRule" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @RecurrenceParentID" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @Annotations" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @Description" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @Reminder" & vbCrLf)

 

insertCommand.Append(vbTab & vbTab &

", @LastModified" & vbCrLf)

 

insertCommand.Append(vbTab &

")" & vbCrLf)

 

 

Dim cmd As New MySqlCommand(insertCommand.ToString, New MySqlConnection(GetConnectionString()))

 

cmd.CommandType = CommandType.Text

cmd.Parameters.Add(

New MySqlParameter("@Subject", appointment.Oggetto))

 

cmd.Parameters.Add(

New MySqlParameter("@Start", appointment.DataInizio))

 

cmd.Parameters.Add(

New MySqlParameter("@End", appointment.DataFine))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@UserID", 1))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@RoomID", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@RecurrenceRule", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@RecurrenceParentID", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@Annotations", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@Description", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@Reminder", Nothing))

 

cmd.Parameters.Add(

New MySqlParameter("@LastModified", Nothing))

 

cmd.Connection.Open()

cmd.ExecuteNonQuery()

cmd.Connection.Close()

 

 

 

 

End Sub

 

 

 

 

<DataObjectMethod(DataObjectMethodType.Update)> _

 

Public Shared Function UpdateAppointment(ByVal appointment As AppointmentItem) As Integer

 

 

 

 

Dim updateCommand As New StringBuilder

 

updateCommand.Append(

"UPDATE" & vbCrLf)

 

updateCommand.Append(vbTab &

"appointments" & vbCrLf)

 

updateCommand.Append(

"SET" & vbCrLf)

 

updateCommand.Append(vbTab &

"Subject = @Subject" & vbCrLf)

 

updateCommand.Append(vbTab &

", Start = @Start" & vbCrLf)

 

updateCommand.Append(vbTab &

", End = @End" & vbCrLf)

 

updateCommand.Append(vbTab &

", UserID = @UserID" & vbCrLf)

 

updateCommand.Append(vbTab &

", RoomID = @RoomID" & vbCrLf)

 

updateCommand.Append(vbTab &

", RecurrenceRule = @RecurrenceRule" & vbCrLf)

 

updateCommand.Append(vbTab &

", RecurrenceParentID = @RecurrenceParentID" & vbCrLf)

 

updateCommand.Append(vbTab &

", Annotations = @Annotations" & vbCrLf)

 

updateCommand.Append(vbTab &

", Description = @Description" & vbCrLf)

 

updateCommand.Append(vbTab &

", Reminder = @Reminder" & vbCrLf)

 

updateCommand.Append(vbTab &

", LastModified = @LastModified" & vbCrLf)

 

updateCommand.Append(

"WHERE" & vbCrLf)

 

updateCommand.Append(vbTab &

"ID = @ID" & vbCrLf)

 

 

Dim cmd As New MySqlCommand(updateCommand.ToString, New MySqlConnection(GetConnectionString()))

 

cmd.CommandType = CommandType.Text

cmd.Parameters.Add(

New MySqlParameter("@Subject", appointment.Oggetto))

 

cmd.Parameters.Add(

New MySqlParameter("@Start", appointment.DataInizio))

 

cmd.Parameters.Add(

New MySqlParameter("@End", appointment.DataFine))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@UserID", appointment.UserID))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@RoomID", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@RecurrenceRule", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@RecurrenceParentID", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@Annotations", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@Description", Nothing))

 

 

 

 

cmd.Parameters.Add(

New MySqlParameter("@Reminder", Nothing))

 

cmd.Parameters.Add(

New MySqlParameter("@LastModified", Nothing))

 

cmd.Parameters.Add(

New MySqlParameter("@ID", appointment.ID))

 

cmd.Connection.Open()

 

Dim i As Integer = cmd.ExecuteNonQuery()

 

cmd.Connection.Close()

 

Return i

 

 

End Function

 

 

 

 

<DataObjectMethod(DataObjectMethodType.Delete)> _

 

Public Shared Function DeleteAppointment(ByVal appointment As AppointmentItem) As Integer

 

 

 

 

Dim deleteCommand As New StringBuilder

 

deleteCommand.Append(

"DELETE" & vbCrLf)

 

deleteCommand.Append(

"FROM" & vbCrLf)

 

deleteCommand.Append(vbTab &

"appointments" & vbCrLf)

 

deleteCommand.Append(

"WHERE" & vbCrLf)

 

deleteCommand.Append(vbTab &

"ID = @ID" & vbCrLf)

 

 

Dim cmd As New MySqlCommand(deleteCommand.ToString, New MySqlConnection(GetConnectionString()))

 

cmd.CommandType = CommandType.Text

cmd.Parameters.Add(

New MySqlParameter("@ID", appointment.ID))

 

cmd.Connection.Open()

 

Dim i As Integer = cmd.ExecuteNonQuery()

 

cmd.Connection.Close()

 

Return i

 

 

End Function

 

End

 

Class

 

0
Veronica
Telerik team
answered on 14 Jan 2011, 05:01 PM
Hi Danilo,

The pasted code is very hard to format and run.
Could you please send me a runnable project so I can inspect it and help you?

Thank you!

Greetings,
Veronica Milcheva
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.
0
Danilo
Top achievements
Rank 1
answered on 14 Jan 2011, 07:27 PM
How or where can i send u a runnable project, please? In this forum it seem is possible to attach only image.
Thank's
Danilo
0
Danilo
Top achievements
Rank 1
answered on 17 Jan 2011, 05:27 PM
Maybe the first execution of the operation (delete, insert, update) is called from the confirmdialog. Coul'd be right?
Thank's
Danilo
0
Veronica
Telerik team
answered on 19 Jan 2011, 02:55 PM
Hi Danilo,

As I see your status is "No Active Support" and by default we don't answer to  such clients. However I'll make an exception for you. Please attach your code to one of the sites for free online storage and send me the link. For example : http://www.4shared.com/.

I'll do the needful to inspect it and help you.

Best wishes,
Veronica Milcheva
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.
0
Danilo
Top achievements
Rank 1
answered on 24 Jan 2011, 10:12 PM
Hi Veronika,
this is the link where u can download the project :
http://www.4shared.com/file/KX_FMguI/scheduler_ObjectDatasource.html

Into the visual studio project you'll find a readme file where there are the step to reproduce the behaviour.

Thank'you very much for you'r availability
Danilo
0
Veronica
Telerik team
answered on 27 Jan 2011, 02:39 PM
Hello Danilo,

Unfortunately we don't work with MySQL. Can you convert the project to SQL Database and Sql connection and I will try to help you.

Thank you!

Greetings,
Veronica Milcheva
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.
Tags
Scheduler
Asked by
Danilo
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Danilo
Top achievements
Rank 1
Share this question
or