469,945 Members | 1,348 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

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

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
Mar 4 '07 #1
2 3902
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

"BenCoo" wrote:
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
Mar 4 '07 #2
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
"BenCoo" wrote:
Hello Muhammad,

Thanks for your answer, but I think that my code is OK. As you asked I send
the code in attachment.

Hope you can find something,

Benny
"Muhammad Mosa" <Mu**********@discussions.microsoft.comschreef in bericht
news:F4**********************************@microsof t.com...
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

"BenCoo" wrote:
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


Mar 4 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by mercercreek | last post: by
9 posts views Thread by mike7510uk | last post: by
reply views Thread by =?Utf-8?B?SGVtYW50?= | last post: by
3 posts views Thread by =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post: by
1 post views Thread by janetb | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.