Solved

How to get checkboxlist value from database

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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