Solved

How to get checkboxlist value from database

Posted on 2011-03-11
1
341 Views
Last Modified: 2012-05-11
I am saving value of checkbox list into database by 26,27 but I want when I visit that form checkbox with that value already checked.

Inshort I want to get checkboxlist value from database.

Can anyone please tell me how to do taht.
0
Comment
Question by:itgirl7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35113327
Hi,

I am going to assume that you CheckBoxList is bounded to a datatable named dt, that have 2 columns, Name and Status, os the code below will loop the datasource and assign the check mark to according to the value of Status


CheckBoxList1.DataSource = dt
        CheckBoxList1.DataTextField = "Name"
        CheckBoxList1.DataBind()

        For Each dr In dt.Rows

            Dim checkItem As ListItem
            checkItem = CheckBoxList1.Items.FindByText(dr("Name").ToString)
            If checkItem IsNot Nothing Then
                If dr("Status") = 1 Then
                    checkItem.Selected = True
                End If
            End If

        Next

Open in new window

0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question