Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

checkbox ? boolean, bit and int16 - datasource controls?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jobs - 21 Jul 2007 17:14 GMT
What's messed up here is that i have close to identical code that is
working perfectly, only difference is that code uses sqldatasource
control instead objectdatasource used here.

Getting this error during the update:

Server Error. To return to your data and retry, use the BACK button
System.ArgumentException: Object of type 'System.Int16' cannot be
converted to type 'System.Boolean'. at
System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo
culture, BindingFlags invokeAttr) at System.Reflection.MethodBase

Column in table :
bit

formview control:
                                   <asp:CheckBox    ID="Active"
SkinID="retailer" runat="server"   Checked='<%# Bind("Active") %>' />

vb class:
           ByVal active As Boolean

.Parameters.Add("@Active", SqlDbType.Bit).Value = Active

Objectdatasource update parm:

<asp:Parameter Name="Active" Type="Int16" DefaultValue="1" />

The data displays perfect with the checkbox checked while in edit.

Thanks for any help or information.
Brandon Gano - 21 Jul 2007 17:58 GMT
The problem is that you can implicitly convert from bit to int16 when
displaying the data, but you cannot convert from int16 to bit when saving
the data.

Change your parameter as follows (not tested):

<asp:Parameter Name="Active" Type="Boolean" DefaultValue="true" />

> What's messed up here is that i have close to identical code that is
> working perfectly, only difference is that code uses sqldatasource
[quoted text clipped - 27 lines]
>
> Thanks for any help or information.
jobs - 21 Jul 2007 22:51 GMT
thank you. I got it working using double and float.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.