checkbox ? boolean, bit and int16 - datasource controls? - DOTNET

This is a discussion on checkbox ? boolean, bit and int16 - datasource controls? - DOTNET ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

checkbox ? boolean, bit and int16 - datasource controls?

  1. Default checkbox ? boolean, bit and int16 - datasource controls?

    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.


  2. Default Re: checkbox ? boolean, bit and int16 - datasource controls?

    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" />


    "jobs" <jobs@webdos.com> wrote in message
    news:1185034442.452846.60980@k79g2000hse.googlegroups.com...
    > 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.
    >



  3. Default Re: checkbox ? boolean, bit and int16 - datasource controls?

    thank you. I got it working using double and float.


+ Reply to Thread

Similar Threads

  1. Problem with boolean controls mechanical action
    By Application Development in forum labview
    Replies: 0
    Last Post: 11-28-2007, 12:10 PM
  2. RadioButton and CheckBox Controls: Where is the value attribute?
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 11-11-2007, 03:29 AM
  3. Re: boolean controls with conditional default values
    By Application Development in forum labview
    Replies: 0
    Last Post: 10-08-2007, 02:10 PM
  4. Three state CheckBox for DataColumn of type Boolean in DataGrid
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 02-10-2005, 04:57 AM
  5. Replies: 1
    Last Post: 04-21-2004, 04:48 PM