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

Appointment Template With ASP:image visible based on databinding

2 Answers 88 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
JK
Top achievements
Rank 1
JK asked on 20 Jun 2008, 10:06 AM
Hi I have a scheduler thaat utilises a appointment template.  I need the appointment to display a graphic if the appointment has not yet been completed. 

This is worked out with my SQL datasource and a field is returned called "IsNotComplete", this feild is a boolean which obviously returns true/false. 

I then have set the scheduler to utilise this field in the CustomAttributeNames section.
I then coded the following inside the scheduler

 <AppointmentTemplate > 
                          
  <TABLE cellSpacing=0 cellPadding=0 width="100%">  
  <TBODY><TR><TD><%# Eval("Subject") %></TD>  
  <TD vAlign=top>  
<asp:Image id="AppointmentNotComplete" runat="server" ImageUrl="~/Images/warning_icon.gif" ToolTip="Incomplete"   
Visible='<%# Eval("IsNotComplete") %>' 
 ImageAlign="Top"></asp:Image> 
</TD></TR></TBODY></TABLE>  
                       
                                      
                                      
</AppointmentTemplate>   
When I open the page in my browser(IE7) I get the following message "Specified Cast Is Invalid". I then adjusted my code to display the content of the eval statement like so:
                        <AppointmentTemplate > 
                          
  <TABLE cellSpacing=0 cellPadding=0 width="100%">  
  <TBODY><TR><TD><%# Eval("IsNotComplete") %> 
  </br> 
  <%# Eval("Subject") %></TD>  
  <TD vAlign=top>  
<asp:Image id="AppointmentNotComplete" runat="server" ImageUrl="~/Images/warning_icon.gif" ToolTip="Incomplete"   
Visible='true' 
 ImageAlign="Top"></asp:Image> 
</TD></TR></TBODY></TABLE>  
                       
                                      
                                      
</AppointmentTemplate> 
The page is then viewable and the value on the apointments clearly shows either "True" or "False".
I then reverted to the first code snippet (top) and added visible='<%# (bool)Eval("IsNotComplete") %>' just incase there was some kind of casting problem but it still errored with "Specified Cast Invalid"

My question is why does the true/false value cause a cast issue?  Is there any where of fixing it?


2 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 20 Jun 2008, 02:11 PM
Hello JK,

The custom attributes are in fact converted to strings. You will need to parse the value to get a boolean. We are planning to also associate the raw data item with the appointment, so you will be able to access the value directly.

<%# Convert.ToBoolean(Eval("IsNotComplete")) %> 


All the best,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Steven
Top achievements
Rank 1
answered on 30 Jul 2012, 09:09 PM
deleted
Tags
Scheduler
Asked by
JK
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Steven
Top achievements
Rank 1
Share this question
or