checkboxes

J

JW

Hi

I am using a checkbox on a ASP form with a SQL database.

<Parameter Name="@Patch" Value='<%# IIf((Request.Form("Patch") <> Nothing),
Request.Form("Patch"), "") %>' Type="NChar" />
<td><asp:CheckBox ID="Patch" runat="server" Enabled="true" /></td>

I need the checkbox to return a value of 1 when checked and 0 when not
checked.
At the moment it returns on when checked and nothing when not checked.

Can anyone give me some pointers please.

Thanks
Jaco
 
P

Patrice

By design an unchecked checkbox doesn't post anything to the server when not
checked plus (AFAIK) the Checkbox server control doesn't support the use of
the value property (you could try an HtmlInputCheckBox instead).

I would do it the .NET way that is the checked property is either True or
False which maps automatically to a BIT whose values is 0 or 1 in SQL Server
(unless you try to achieve something else, for now it loks like you are
trying to do something that is already handled by .NET).

You could use IsPostBack to known if this is the first hit (in case it is
what you are after as I noticed you check Patch for "nothing").
 

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,786
Messages
2,569,625
Members
45,320
Latest member
icelord

Latest Threads

Top