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

Hyperlink as subject

1 Answer 60 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
H.
Top achievements
Rank 1
H. asked on 12 Sep 2011, 11:19 PM
I create an Appointment template dynamically and I want to create a Hyperlink as subject. The problem that I have is that I need to use a value of the Datatable that is datasource of the RadScheduler. See definition of the DataTable.  IN the AppointmentDataBound I know I can use the DataRowVIew to get the values of the DataItem but in the Appointment Template does not work. How can I get the values of the DataItem in the appointment Template? See the appointment template below.


 

 

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;

}

}

}

}

}

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 14 Sep 2011, 11:51 AM
Hello H.,

Please, try the approach from this kb article -
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/creating-and-adding-an-appointment-template-dynamically-and-accessing-the-appointment-object-in-the-template-class.aspx.


Greetings,
Peter
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
H.
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or