Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 May 28th, 2006, 05:25 AM
Authorized User
 
Join Date: Jan 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select CheckBoxList Base on Value Retrieve Drom DB

Hi, I have store some value in database. Eg Sales. I have a checkboxlist contains items populate from the database. I want to select the checkbox item if the value matches.

   For i = 0 To products.Items.Count - 1

'How should i do the For Loop comparing the values?

                    Exit For
                End If
            Next
        Next

Please advise, thanks alot

 
Old May 28th, 2006, 03:39 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You have to pull the values into a datatable or dataset and loop through the table and and table then compre values and set the selected property as needed.

 
Old May 28th, 2006, 10:56 PM
Authorized User
 
Join Date: Jan 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I store the value that i retrieve from the database in "mycode". When I try to start the page it gives me error. Is my coding wrong?

        Dim mycode As String()
        Dim i As Integer
        Dim currentcheckbox As ListItem

        mycode = activate.showAllRequestCode(sfID)

        For i = 0 To cbl_Codes.Items.Count - 1

            currentcheckbox = cbl_Codes.Items.FindByValue(Convert.ToString(mycod e))

            If Not (currentcheckbox Is Nothing) Then
                currentcheckbox.Selected = True
            End If
        Next

 
Old May 29th, 2006, 09:54 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

what is the error and on what line?

 
Old May 30th, 2006, 03:52 AM
Authorized User
 
Join Date: Jan 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It ok jbenson001, I resolve it already. Thanks for your help :)

 
Old May 30th, 2006, 09:02 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

ok

 
Old May 30th, 2006, 09:58 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

What did you do to fix it? What was the problem? Maybe we all could learn something.






Similar Threads
Thread Thread Starter Forum Replies Last Post
repopulating CheckBoxList from db table problem enginev ASP.NET 2.0 Basics 0 April 1st, 2008 07:22 AM
Retrieve image data from mysql db vermaarun2005 PHP Databases 0 July 14th, 2007 11:12 AM
How to store and retrieve formatted strings in db jessi Classic ASP Professional 2 March 9th, 2007 07:27 AM
Ani 1 noe how to retrieve record from select max() babymeizi Pro JSP 2 October 14th, 2004 05:11 PM





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