Skip to main content
Participant
November 1, 2012
Question

Dynamic Checkbox not Populating from Database

  • November 1, 2012
  • 1 reply
  • 639 views

Using a simple insert record then pull info from database and update record web page, however the checkboxes on the update page are not pulling the existing information from the database. The checkbox (checkbox 1,0) is writing '1' to the database when checked and the record added, but the update page does not show the checkbox to be checked on the update page.

Here is the code for the checkbox on the update page:

<input <%If (CStr((print_jobs.Fields.Item("pjVarnish").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="pjVarnish" value="1" />

Any ideas?

This topic has been closed for replies.

1 reply

Participating Frequently
November 1, 2012

Try this instead:

<input <%If (CStr(print_jobs.Fields.Item("pjVarnish").Value) = CStr("1")) Then Response.Write("checked") %> type="checkbox" name="pjVarnish" value="1" />

Also, why are you converting the field you are testing to a string? What is the datatype in the db? If numeric or boolean why not just:

<input <%If (print_jobs.Fields.Item("pjVarnish").Value) = 1) Then Response.Write("checked") %> type="checkbox" name="pjVarnish" value="1" />