protected void RadScheduler_AppointmentDataBound(object sender, SchedulerEventArgs e)
{
if (e.Appointment.DataItem != null)
{
int argb = Int32.Parse(((System.Data.DataRowView)(e.Appointment.DataItem)).Row.ItemArray[11].ToString().Replace("#", ""), NumberStyles.HexNumber);
e.Appointment.BackColor =
Color.FromArgb(argb);
}
}
/*****DataTable definition*****/
DataTable
dtAppointments = new DataTable("Appointments");
dtAppointments.Columns.Add(
"ItemID", typeof(string));
dtAppointments.Columns.Add(
"Title", typeof(string));
dtAppointments.Columns.Add(
"CalendarType", typeof(string));
dtAppointments.Columns.Add(
"StartDate", typeof(DateTime));
dtAppointments.Columns.Add(
"EndDate", typeof(DateTime));
dtAppointments.Columns.Add(
"hasEndDate", typeof(bool));
dtAppointments.Columns.Add(
"Description", typeof(string));
dtAppointments.Columns.Add(
"Location", typeof(string));
dtAppointments.Columns.Add(
"RecurrenceRule", typeof(string));
dtAppointments.Columns.Add(
"RecurrenceParentID", typeof(Int64));
dtAppointments.Columns.Add(
"IsRecurrence", typeof(bool));
dtAppointments.Columns.Add(
"Color", typeof(string));
dtAppointments.Columns.Add(
"NavigationUrl",typeof(string));
/******* AppointTemplate Class.I took this from the forum*****/
public class AppTemplate : ITemplate
{
public void InstantiateIn(Control container)
{
Literal subject = new Literal();
subject.DataBinding += subject_DataBinding;
container.Controls.Add(subject);
}
private void subject_DataBinding(object sender, EventArgs e)
{
Literal subject = (Literal)sender;
IDataItemContainer aptContainer = (IDataItemContainer)subject.BindingContainer;
int argb = Int32.Parse(((System.Data.DataRowView)(aptContainer.DataItem)).Row.ItemArray[11].ToString().Replace("#", ""), NumberStyles.HexNumber);
int lId = Convert.ToInt32(DataBinder.Eval(aptContainer.DataItem, "ID"));
string strSubject = HttpUtility.HtmlEncode((string)DataBinder.Eval(aptContainer.DataItem, "Subject"));
SPWeb oWeb = null;
oWeb =
SPContext.Current.Web;
String requestListName = "TravelCalendarList";
SPListItem itm = oWeb.Lists[requestListName].GetItemById(Convert.ToInt32(lId));
if (itm != null)
{
if (null != itm["RequestId"])
{
subject.Text =
"<a href=\"" + oWeb.Url + "/default.aspx?ListId=" + lId + "\">" + strSubject + "</a>";
}
else
{
subject.Text = strSubject;
}
}
}
}
}