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

B

BenCoo

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
 
G

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
 
G

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top