Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2005, 10:49 AM
Authorized User
 
Join Date: May 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.Net Checkbox

I want to retrieve the value from a database for a checkbox, the value in the db is 1 for checked and 0 for unchecked. At the moment the word 'True' is being displayed next to the checkbox rather than being checked. here is my code:

<asp:checkbox ID="txtProduct_Visible" runat="server" />

Sub LoadProduct()
  Connect()
  Dim strQuery As String = "SELECT ProdRange_Visible " & _
                           "FROM dbo.Product_Range WHERE ProdRangeID = " & Request("ProdRangeID")

  Dim dbComm As New SqlCommand(strQuery, objConnection)
  Dim reader As SqlDataReader = dbComm.ExecuteReader()

  reader.Read()

  txtProduct_Visible.Text = reader.GetValue(0)

  reader.Close()
  Disconnect()
End Sub


 
Old September 21st, 2005, 02:22 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

change this:
txtProduct_Visible.Text = reader.GetValue(0)

To this:
txtProduct_Visible.Checked = reader.GetValue(0)

 
Old September 22nd, 2005, 04:30 AM
Authorized User
 
Join Date: May 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks mate, I thought it was something like that, I tried:

txtProduct_Visible.CheckBox = reader.GetValue(0)

Works fine

 
Old September 22nd, 2005, 08:56 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Glad to help..

Jim






Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Checkbox selection - ASP cancer10 Classic ASP Databases 7 November 21st, 2006 01:00 AM
CheckBox enable in asp 2.0 with javascript bbsdev Javascript How-To 0 July 18th, 2006 12:27 PM
Asp.Net Checkbox in Datagrid. vivek_inos C# 2 December 5th, 2005 02:40 PM
ASP.NET C# - Trouble with checkbox booksnore2 General .NET 1 October 5th, 2004 11:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.