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

CheckBox Syntax in Advanced Edit Form

5 Answers 100 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 07 Apr 2008, 06:25 PM

I'm getting a "Specified cast is not valid" error related to a checkbox on my Advanced Edit form in Scheduler.

The database field is a bit type.

Here is the code...

ASPX:

            <table cellpadding="0" cellspacing="0" border="0">  

                <tr> 

                    <td><b>Title</b></td>  

                    <td>&nbsp;</td> 

                </tr> 

                <tr> 

                    <td><asp:TextBox runat="server" ID="EventTitleTemp" Text='<%# Eval("EventTitle") %>' Width="240px"></asp:TextBox></td>  

                    <td><div style="margin-bottom:3px;"><asp:CheckBox runat="server" ID="EventActiveTemp" Checked='<%# Convert.ToBoolean(Eval("EventActive")) %>' style="padding: 0em; margin: 0em; vertical-align: middle;"></asp:CheckBox> Active</div></td>  

                </tr> 

            </table> 

Code Behind:

        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]  

        public bool EventActive  

        {  

            get  

            {  

                return EventActiveTemp.Checked;  

            }  

 

            set  

            {  

                EventActiveTemp.Checked = value;  

            }  

        } 

Am I missing something? Doing this totally wrong? Any help would be appreciated.

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 10 Apr 2008, 04:22 PM
Hello Joseph,

Please, see if the following google search result can help you:

http://www.google.com/search?q=Specified+cast+is+not+valid&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1

You may need to explicictly convert the bit values to type bool.

All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
illumination
Top achievements
Rank 2
answered on 05 Aug 2008, 08:35 PM
I am having the same problem here. Does anybody have the answer? I went to that search link but came up empty. Please let me know...

Thank you so much!
0
T. Tsonev
Telerik team
answered on 06 Aug 2008, 03:14 PM
Hello,

I have just replied to the support ticket that you have opened. I am attaching a custom control (BooleanAttributeControl) that is designed to work with Boolean values. The usage is the same as the CustomAttributeControl, but instead of a text box it renders a check box.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Matt Johnston
Top achievements
Rank 1
answered on 14 Jan 2009, 06:03 PM
Hi,

I'm fairly new to using your controls (and .net for that matter) and ran across the noted issue with using a checkbox.  

Can you give the line of code to register the control on an aspx page and also the code to add the control to the page. This would help out a lot.

thanks in advance,

Matt
0
Peter
Telerik team
answered on 15 Jan 2009, 11:47 AM
Hi Matt,

Could you please elaborate on your scenario and explain what exactly you need to implement? Note that the BooleanAttributeControl user control which Tsvetomir attached to this thread is intended to be used for the Scheduler's advanced template as in this example.


Regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
Joseph
Top achievements
Rank 1
Answers by
Peter
Telerik team
illumination
Top achievements
Rank 2
T. Tsonev
Telerik team
Matt Johnston
Top achievements
Rank 1
Share this question
or