value of checked box!?

J

Jerome

Hi,

I've got the following problem:

I'm retrieving data from an SQL Server database. And I want my form to
display a checked box in the state corresponding to the value saved in
the DB. But somehow that doesn't work!?

SQL tells me the value is 1.
My ASP page tells me it's 'True'??

So I tried it like this:
<input name="checkbox" type="checkbox" value="checkbox" <%If
rsDemande.Fields.Item("lien").Value = 1 Then Response.Write("
checked='checked'") : Response.Write("")%>>

and like this:

<input name="checkbox" type="checkbox" value="checkbox" <%If
cstr(rsDemande.Fields.Item("lien").Value) = "True" Then Response.Write("
checked='checked'") : Response.Write("")%>>

But neither works. The checkbox remains unchecked!?

What am I doing wrong?

Thanks a lot,

Jerome
 
A

Aaron [SQL Server MVP]

Did you try = "1" ? What is the datatype in the SQL Server database?

Followups to asp.db only.
 
M

McKirahan

Jerome said:
Hi,

I've got the following problem:

I'm retrieving data from an SQL Server database. And I want my form to
display a checked box in the state corresponding to the value saved in
the DB. But somehow that doesn't work!?

SQL tells me the value is 1.
My ASP page tells me it's 'True'??

So I tried it like this:
<input name="checkbox" type="checkbox" value="checkbox" <%If
rsDemande.Fields.Item("lien").Value = 1 Then Response.Write("
checked='checked'") : Response.Write("")%>>

and like this:

<input name="checkbox" type="checkbox" value="checkbox" <%If
cstr(rsDemande.Fields.Item("lien").Value) = "True" Then Response.Write("
checked='checked'") : Response.Write("")%>>

But neither works. The checkbox remains unchecked!?

What am I doing wrong?

Thanks a lot,

Jerome

When you're through it should look like this:

<input name="checkbox" type="checkbox" value="checkbox" checked>

My guess is that yours will look like this:

<input name="checkbox" type="checkbox" value="checkbox" checked='checked'>

Change your code to:

<%
Dim strCHK
If CStr(rsDemande.Fields.Item("lien").Value) = "True" Then strCHK = "
checked"
%>

<input name="checkbox" type="checkbox" value="checkbox"<%=strCHK%>>
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top