Saving a checkbox value from a gridview into a sqlserver 2005 database

Discussion in 'ASP .Net' started by BenCoo, Mar 4, 2007.

  1. BenCoo

    BenCoo Guest

    Hello,

    In a gridview I've a checkbox (indicating a flag that is set or not). I fill
    the gridview via the wizard from ADO.NET 2.0 that generates automaticly the
    Insert, Update and Delete commands. I've also added the button Edit to the
    grid that activate the Update- and cancelbuttons. When afther I set the grid
    in updatemode, change the value in het checkbox and click on the
    updatebutton I get the error:

    "An error occured. Cannot insert the value NULL into column 'FlagName',
    table 'RDPMS.dbo.Flag'; column does not allow nulls. UPDATE fails. The
    statement has been terminated."

    What I'm doing wrong ?

    Oohh yes : the field in the sqldatabase is a Bit-type while there is no
    boolean variable-type in sqlserver.

    (See also postings on microsoft.public.dotnet.languages.vb.data (Fev 28,
    2007) - that's wy I post the question here...

    Thanks in advance for any help on this !

    Benny
     
    BenCoo, Mar 4, 2007
    #1
    1. Advertisements

  2. BenCoo

    Guest Guest

    I don know if you are using CheckBoxField or edit item template, it would be
    better if you could submit snippet of your gridview aspx code.
    anyway, your error take place when there is no parameter value is sent -this
    initialize the parameter with null- to the update statement.
    This typically could happen if you are using edit item template where you
    manually add your check box.
    if this is your case, you should update your checkbox to be as the following:
    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#
    Bind("Discontinued") %>' />

    Hope this would help
    --
    Muhammad Mosa
    Software Engineer & Solution Developer
    MCT/MCSD.NET
    MCTS: .Net 2.0 Web Applications
    MCTS: .Net 2.0 Windows Applications
    MCPD: Enterprise Application Developer
     
    Guest, Mar 4, 2007
    #2
    1. Advertisements

  3. BenCoo

    Guest Guest

    Sorry but I couldn't find your could, where the attachement?!
    --
    Muhammad Mosa
    Software Engineer & Solution Developer
    MCT/MCSD.NET
    MCTS: .Net 2.0 Web Applications
    MCTS: .Net 2.0 Windows Applications
     
    Guest, Mar 4, 2007
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.