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

How to find the controls in my AppointmentTemplate from AppointmentDataBound

2 Answers 279 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Susan Sun
Top achievements
Rank 1
Susan Sun asked on 26 May 2011, 08:39 PM
Hello,

I am using telerisk scheduler with the code below:

<

 

telerik:RadScheduler ID="rsDaySchedule" Height="2093px" BorderStyle="None" ShowNavigationPane="false" Width ="100%" ShowViewTabs="false" AllowDelete="False" AllowEdit="true" AllowInsert="False" HoursPanelTimeFormat="h:mmtt" NumberOfHoveredRows="1" RowHeight ="52px" DayStartTime="8:30:00" DayEndTime="13:00:00" SelectedView="DayView" OnAppointmentDataBound="rsDaySchedule_AppointmentDataBound" OnAppointmentCommand="rsDaySchedule_AppointmentCommand" OnAppointmentClick="rsDaySchedule_AppointmentClick" MinutesPerRow="15" DataSubjectField="OrgName" DataKeyField="ScheduleEntryID" DataStartField="startTime" DataEndField="endTime" CustomAttributeNames="Desicions,DayLeft,ScheduleEntryID,OrgID" EnableCustomAttributeEditing="true" runat="server" style="left: 0px; top:0px" Skin

="Sunset">  

 

<AppointmentTemplate > 

 

<asp:Table ID="Table1" CssClass="OrgInfo" BorderStyle="NotSet" runat="server" Width ="100%" Height="52px" >

 

 

<asp:TableRow Height="30px">

 

<asp:TableCell Width ="109px">

<asp:Label ID="lblOrgName" runat ="server" Text="Organization Name: "></asp:Label>

 

</asp:TableCell>

 

 

<asp:TableCell Width ="339px">

 

 

<asp:Label ID="txtOrgName" runat ="server" Font-Bold="true" Text='<%# Eval("Subject") %>'></asp:Label> 

 

 

 

 

 

</asp:TableCell>
<asp:TableCell Width ="228px">

 

<asp:Label ID="lblDecision" runat ="server" Text="Decision: "></asp:Label>

<asp:Label ID="txtDecision" runat ="server" Font-Bold="true" Text='<%# Eval("Desicions") %>'></asp:Label>

&nbsp;&nbsp;

 

</asp:TableCell>
<asp:TableCell Width="82px">
<asp:Label ID="lblDayLeft" runat ="server" Text="Days Left: "></asp:Label>&nbsp;&nbsp;

 

 

<asp:Label ID="txtDayLeft" runat ="server" Font-Bold="true" Text='<%# Eval("DayLeft") %>'></asp:Label>

 

<asp:HiddenField ID="hdScheduleEntryID" Value ='<%# Eval("ScheduleEntryID") %>' runat="server" />

 

 

<asp:HiddenField ID="hdOrgID" Value ='<%# Eval("OrgID") %>' runat="server"/>

 

 

</asp:TableCell>

 

 

</asp:TableRow>

 

 

<asp:TableRow Height="21px">

 

<asp:TableCell >

</asp:TableCell>
<asp:TableCell>
</asp:TableCell>
<asp:TableCell >
<sp:LinkButton ID="lbtnResche" runat="server" ForeColor="Blue" CommandName="Reschedule" Text="Reschedule"></asp:LinkButton>&nbsp;&nbsp;
<asp:LinkButton ID="lbtnRatings" runat="server" ForeColor="Blue" CommandName="EditRating" Enabled="True" Text="Edit Ratings"></asp:LinkButton &nbsp;&nbsp; <asp:LinkButton ID="lbtnNext" runat="server" ForeColor="Blue" CommandName="More" Text="More info ..." > </asp:LinkButton>
</asp:TableCell>
</asp:TableRow>

 

 

</asp:Table>
</AppointmentTemplate>

 

 

</telerik:RadScheduler>

My requestion is "How to find the controls in my AppointmentTemplate from AppointmentDataBound?"

How come in my

 

 

 

Protected Su

 

b rsDaySchedule_AppointmentDataBound(ByVal sender As Object, ByVal e As

SchedulerEventArgs)

 

 

 

 

 

 

Dim lbtnRatings As LinkButton = CType(e.Appointment.AppointmentControls(0).FindControl("lbtnRatings"), LinkButton)

I get error message -- Index was out of range.

 &

e.Appointment.AppointmentControls.count =0  always !

 

 

 

Please help ! Thanks a lot!

 

2 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 27 May 2011, 09:04 AM
Hi Susan,

I'll suggest you using the OnAppointmentCreated server-side event instead. You can easily access the controls inside the AppointmentTemplate via the e.Container.FindControl() function as shown inthis demo.

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
Susan Sun
Top achievements
Rank 1
answered on 27 May 2011, 03:16 PM
Thanks a lot!
It works now. :-)
Tags
Scheduler
Asked by
Susan Sun
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Susan Sun
Top achievements
Rank 1
Share this question
or