Hi I have a major problem.
I initiate a RadSchedular by code
I set the template also by code. When I first load the page, and bind the data, the appointments display perfectly (dataset1).
When I query another dataset(dataset2) and bind the appointment template does not refresh, although the resources are displayed correctly.
If I go back to the first dataset (dataset1) and bind that again, then the template displayes the appointments again.
somehow for the second datset, its as though the template does not refresh. I am urgently needing a reply.
Can you help to reply. Thanks.
(
shehan@ares.com.au)
RadScheduler radSchedular =
new
RadScheduler();
radSchedular.ID =
"BookingTimeSlotsRadSchedular"
;
radSchedular.Enabled =
true
;
radSchedular.DataKeyField =
"BookingTimeSlotId"
;
radSchedular.DataStartField =
"StartDateTime"
;
radSchedular.DataEndField =
"EndDateTime"
;
radSchedular.DataSubjectField =
"StaffName"
;
radSchedular.MinutesPerRow = interview.Duration;
radSchedular.DayStartTime = Convert.ToDateTime(session.DateFrom).TimeOfDay;
radSchedular.DayEndTime = Convert.ToDateTime(session.DateTo).TimeOfDay;
radSchedular.SelectedView = SchedulerViewType.DayView;
radSchedular.SelectedDate = Convert.ToDateTime(session.DateFrom);
radSchedular.TimelineView.UserSelectable =
false
;
radSchedular.WeekView.UserSelectable =
false
;
radSchedular.MonthView.UserSelectable =
false
;
radSchedular.DayView.UserSelectable =
false
;
radSchedular.CustomAttributeNames =
new
string
[] {
"BookingTimeSlotId"
,
"InterviewId"
,
"SessionId"
,
"StaffId"
,
"StaffName"
,
"ParentId"
,
"ParentName"
,
"StartDateTime"
,
"EndDateTime"
,
"StudentId"
,
"StudentName"
,
"Booked"
,
"Active"
,
"SelectionLimit"
,
"CreateDate"
,
"ModifiedDate"
,
"ModifiedBy"
,
"Ts"
,
"SelectedStudentId"
,
"SelectedParentId"
,
"SelectedInterviewId"
,
"SelectedSessionId"
};
//Resources--------------------------------------------------
ResourceType staffResType =
new
ResourceType(
"Staffs"
);
staffResType.DataSource = staffResources;
staffResType.ForeignKeyField =
"StaffId"
;
staffResType.KeyField =
"StaffId"
;
staffResType.TextField =
"StaffName"
;
radSchedular.ResourceTypes.Add(staffResType);
//radSchedular.Resources.Add(new Resource("Foreman", 160, "A"));
//radSchedular.Resources.Add(new Resource("Foreman", 529, "B"));
//-------------------------------------------------------------
//Appointment Template---------------------------------------
radSchedular.Appointments.Clear();
AppTemplate apptmp =
new
AppTemplate();
radSchedular.AppointmentTemplate = apptmp;
//----------------------------------------------------------
radSchedular.GroupBy =
"Staffs"
;
radSchedular.GroupingDirection = GroupingDirection.Horizontal;
radSchedular.DataSource = bookingtimeslots;
radSchedular.ReadOnly =
false
;
radSchedular.AppointmentDataBound +=
new
AppointmentDataBoundEventHandler(radSchedular_AppointmentDataBound);
radSchedular.AppointmentCommand +=
new
AppointmentCommandEventHandler(radSchedular_AppointmentCommand);
radSchedular.DataBind();
this
.PlaceHolderBookingTimeSlots.Controls.Add(radSchedular);
//=================================================================================
public
class
AppTemplate : ITemplate
{
public
void
InstantiateIn(Control container)
{
Literal ltlApptDisplay =
new
Literal();
ltlApptDisplay.ID =
"LtlApptDisplay"
;
ltlApptDisplay.DataBinding += ltlApptDisplay_DataBinding;
container.Controls.Add(ltlApptDisplay);
//CheckBox chkSelectBooking = new CheckBox();
//chkSelectBooking.ID = "ChkSelectBooking";
//chkSelectBooking.CheckedChanged += new EventHandler(chkSelectBooking_CheckedChanged);
//chkSelectBooking.AutoPostBack = true;
//chkSelectBooking.Text = "Select";
//container.Controls.Add(chkSelectBooking);
RadButton radButton =
new
RadButton();
radButton.ID =
"radBtnSel"
;
//radButton.Click += new EventHandler(radButton_Click);
radButton.Text =
" Book "
;
radButton.Width =
new
Unit(60);
radButton.CommandName =
"SELECT"
;
container.Controls.Add(radButton);
Literal ltlSpace =
new
Literal();
ltlSpace.ID =
"LtlSpace"
;
ltlSpace.Text =
" "
;
container.Controls.Add(ltlSpace);
RadButton radRelButton =
new
RadButton();
radRelButton.ID =
"radBtnRel"
;
//radRelButton.Click += new EventHandler(radRelButton_Click);
radRelButton.CommandName =
"RELEASE"
;
radRelButton.Width =
new
Unit(60);
radRelButton.Text =
" Release "
;
container.Controls.Add(radRelButton);
}
//void radRelButton_Click(object sender, EventArgs e)
//{
// RadButton radButton = (RadButton)sender;
// SchedulerAppointmentContainer aptCont = (SchedulerAppointmentContainer)radButton.Parent;
// Appointment app = aptCont.Appointment;
// int selApptId = Convert.ToInt32(app.ID);
// this.ModifyBookingTimeSlot(app, true);
//}
//void radButton_Click(object sender, EventArgs e)
//{
// RadButton radButton = (RadButton)sender;
// SchedulerAppointmentContainer aptCont = (SchedulerAppointmentContainer)radButton.Parent;
// Appointment app = aptCont.Appointment;
// int selApptId = Convert.ToInt32(app.ID);
// this.ModifyBookingTimeSlot(app, false);
//}
void
chkSelectBooking_CheckedChanged(
object
sender, EventArgs e)
{
CheckBox chkSelectBooking = (CheckBox)sender;
SchedulerAppointmentContainer aptCont = (SchedulerAppointmentContainer)chkSelectBooking.Parent;
Appointment app = aptCont.Appointment;
int
selApptId = Convert.ToInt32(app.ID);
//string staffId = Convert.ToString(app.Attributes["StaffId"]);
//string selectedStudentId = Convert.ToString(app.Attributes["SelectedStudentId"]);
//string selectedParentId = Convert.ToString(app.Attributes["SelectedParentId"]);
//string selectedInterviewId = Convert.ToString(app.Attributes["SelectedInterviewId"]);
//string selectedSessionId = Convert.ToString(app.Attributes["SelectedSessionId"]);
//"BookingTimeSlotId","InterviewId", "SessionId", "StaffId", "StaffName", "ParentId", "ParentName",
//"StudentId", "StudentName", "Booked", "Active", "SelectionLimit", "CreateDate","ModifiedDate","ModifiedBy","Ts",
//"SelectedStudentId", "SelectedParentId","SelectedInterviewId", "SelectedSessionId"
//this.ModifyBookingTimeSlot(app, chkSelectBooking.Checked);
}
#region ltlApptDisplay_DataBinding
/// <summary>
/// ltlApptDisplay_DataBinding
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
ltlApptDisplay_DataBinding(
object
sender, EventArgs e)
{
Literal ltlApptDisplay = (Literal)sender;
IDataItemContainer aptContainer = (IDataItemContainer)ltlApptDisplay.BindingContainer;
//Access the appointment object and set its AllowEdit property:
SchedulerAppointmentContainer aptCont = (SchedulerAppointmentContainer)ltlApptDisplay.Parent;
Appointment app = aptCont.Appointment;
app.AllowEdit =
false
;
app.AllowDelete =
false
;
RadButton radSelButton = (RadButton)aptCont.FindControl(
"radBtnSel"
);
RadButton radRelButton = (RadButton)aptCont.FindControl(
"radBtnRel"
);
//DateTime StartDateTime = Convert.ToDateTime(DataBinder.Eval(aptContainer.DataItem, "Start"));
//DateTime StartEndTime = Convert.ToDateTime(DataBinder.Eval(aptContainer.DataItem, "End"));
//bookingtimeslot.Text = String.Format("{0} - {1}", StartDateTime, StartEndTime);
string
staffId = Convert.ToString(app.Attributes[
"StaffId"
]);
string
staffName = Convert.ToString(app.Attributes[
"StaffName"
]);
string
parentName = Convert.ToString(app.Attributes[
"ParentName"
]);
string
studentName = Convert.ToString(app.Attributes[
"StudentName"
]);
StringBuilder sb =
new
StringBuilder();
sb.AppendFormat(
"{0} - {1}<br/>"
, app.Start, app.End);
sb.AppendFormat(
"Staff: {0}<br/>"
, staffName);
sb.AppendFormat(
"Parent: {0}<br/>"
, parentName);
sb.AppendFormat(
"Student: {0}<br/>"
, studentName);
ltlApptDisplay.Text = sb.ToString();
if
(app.Attributes[
"Active"
] ==
"True"
)
{
app.BackColor = System.Drawing.Color.Gold;
radSelButton.Enabled =
true
;
radRelButton.Enabled =
false
;
if
(app.Attributes[
"Booked"
] ==
"True"
)
{
if
(Convert.ToInt32(app.Attributes[
"ParentId"
]) == Convert.ToInt32(app.Attributes[
"SelectedParentId"
]))
{
app.BackColor = System.Drawing.Color.YellowGreen;
radSelButton.Enabled =
false
;
radRelButton.Enabled =
true
;
}
else
{
app.BackColor = System.Drawing.Color.LightBlue;
radSelButton.Enabled =
false
;
radRelButton.Enabled =
false
;
}
}
}
else
{
app.BackColor = System.Drawing.Color.LightGray;
radSelButton.Visible =
false
;
radRelButton.Visible =
false
;
}
}
#endregion
}
//==========================================================================