Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to get checkboxlist value from database

Posted on 2011-03-11
1
Medium Priority
?
348 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

610 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