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
Solved

How to get checkboxlist value from database

Posted on 2011-03-11
1
332 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
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 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