I don't understand RadScheduler.
I want to bind from database. Here is my code. Is that right?
I just want to a basic perform. But I think my code is somewhere That's weird.........
In order to rebind(refresh) every time do I need to call GetSchedule()?
(When I removed "IsPostBack" check, code gives me the "Invalid attempt to call FieldCount when reader is closed" error)
So, what's wrong? please, help me somebody. T-T and forgive my basic English skills.
I want to bind from database. Here is my code. Is that right?
I just want to a basic perform. But I think my code is somewhere That's weird.........
In order to rebind(refresh) every time do I need to call GetSchedule()?
(When I removed "IsPostBack" check, code gives me the "Invalid attempt to call FieldCount when reader is closed" error)
So, what's wrong? please, help me somebody. T-T and forgive my basic English skills.
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
class
=
"telerikControls"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
OutputCompression
=
"Disabled"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
language
=
"javascript"
type
=
"text/javascript"
>
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadSchedulerTemplate"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadSchedulerTemplate"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManager1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadSchedulerTemplate"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadButtonNewAppointment"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadSchedulerTemplate"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
</
div
>
<
div
>
<
table
width
=
"100%"
>
<
tr
>
<
td
align
=
"right"
>
<
telerik:RadButton
ID
=
"RadButtonNewAppointment"
runat
=
"server"
EnableEmbeddedSkins
=
"true"
Skin
=
"Default"
Text
=
"New"
Width
=
"60"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadScheduler
ID
=
"RadSchedulerTemplate"
runat
=
"server"
EnableDescriptionField
=
"true"
Height
=
"800"
SelectedView
=
"DayView"
DataKeyField
=
"ID"
DataSubjectField
=
"Subject"
DataStartField
=
"Start"
DataEndField
=
"End"
DataDescriptionField
=
"Description"
DataRecurrenceField
=
"RecurrenceRule"
DataRecurrenceParentKeyField
=
"RecurrenceParentID"
DataReminderField
=
"Reminder"
>
<
AdvancedForm
Modal
=
"true"
/>
<
Reminders
Enabled
=
"true"
/>
<
AppointmentContextMenuSettings
EnableDefault
=
"true"
/>
<
TimeSlotContextMenuSettings
EnableDefault
=
"true"
/>
</
telerik:RadScheduler
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
form
>
</
body
>
Private
Sub
_RadSchedulerDefault_Init(sender
As
Object
, e
As
System.EventArgs)
Handles
Me
.Init
If
Not
IsPostBack
Then
GetSchedule()
End
If
End
Sub
Private
Sub
GetSchedule()
Dim
sqlCommand
As
SqlCommand =
New
SqlCommand
Try
_sqlConnection.ConnectionString =
DBConnectionManager.OpenConnection()
sqlCommand = _sqlConnection.CreateCommand
sqlCommand.CommandType = CommandType.StoredProcedure
sqlCommand.CommandText =
"S_01"
_sqlDataReader = sqlCommand.ExecuteReader
RadSchedulerTemplate.DataSource = _sqlDataReader
Catch
ex
As
Exception
DBConnectionManager.CloseConnection(_sqlConnection, _sqlDataReader)
Finally
DBConnectionManager.CloseConnection(sqlCommand)
End
Try
End
Sub
Private
Sub
RadSchedulerTemplate_DataBound(sender
As
Object
, e
As
System.EventArgs)
Handles
RadSchedulerTemplate.DataBound
DBConnectionManager.CloseConnection(_sqlConnection, _sqlDataReader)
End
Sub
Private
Sub
RadSchedulerTemplate_AppointmentInsert(sender
As
Object
, e
As
Telerik.Web.UI.AppointmentInsertEventArgs)
Handles
RadSchedulerTemplate.AppointmentInsert
Dim
dbConnection
As
SqlConnection =
New
SqlConnection
Dim
dbCommand
As
SqlCommand =
New
SqlCommand
Try
Dim
app
As
Appointment = e.Appointment
Dim
subject
As
String
= app.Subject
Dim
startDate
As
DateTime = app.Start
Dim
endDate
As
DateTime = app.
End
Dim
recurrenceRule
As
String
= app.RecurrenceRule
Dim
recurrenceParentID
As
Integer
= app.RecurrenceParentID
Dim
description
As
String
= app.Description
Dim
reminder
As
String
= app.Reminders.ToString
dbConnection = DBConnectionManager.OpenConnection()
dbCommand = dbConnection.CreateCommand
dbCommand.CommandType = CommandType.StoredProcedure
dbCommand.CommandText =
"S_02"
dbCommand.Parameters.Add(
"@Subject"
, SqlDbType.VarChar).Value = subject
dbCommand.Parameters.Add(
"@StartDate"
, SqlDbType.DateTime).Value = startDate
dbCommand.Parameters.Add(
"@EndDate"
, SqlDbType.DateTime).Value = endDate
If
Not
String
.IsNullOrEmpty(recurrenceRule)
Then
dbCommand.Parameters.Add(
"@RecurrenceRule"
, SqlDbType.VarChar).Value = recurrenceRule
End
If
If
recurrenceParentID <> 0
Then
dbCommand.Parameters.Add(
"@RecurrenceParentID"
, SqlDbType.Int).Value = recurrenceParentID
End
If
If
Not
String
.IsNullOrEmpty(description)
Then
dbCommand.Parameters.Add(
"@Description"
, SqlDbType.VarChar).Value = description
End
If
If
Not
String
.IsNullOrEmpty(reminder)
Then
dbCommand.Parameters.Add(
"@Reminder"
, SqlDbType.VarChar).Value = reminder
End
If
dbCommand.ExecuteNonQuery()
GetSchedule()
Catch
ex
As
Exception
'exception
Finally
DBConnectionManager.CloseConnection(dbConnection,
Nothing
, dbCommand)
End
Try
End
Sub
Private
Sub
RadSchedulerTemplate_NavigationCommand(sender
As
Object
, e
As
Telerik.Web.UI.SchedulerNavigationCommandEventArgs)
Handles
RadSchedulerTemplate.NavigationCommand
GetSchedule()
End
Sub