checkbox list wth database

Posted on 2010-09-08
Last Modified: 2013-12-17
I have one table name having 2 fileds did(int) and dname(nvarchar(20)) and I want to use in CheckBoxList and I want to save it into another table as anyoen selected or not selected so how I will manage thses ids.
Question by:jyotiraman
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
  • 4
  • 3

Expert Comment

ID: 33634051
When you load the data into list box you have to load the ids into value property and the name should be visible. example for you.

<form action="">
<input type="radio" name="rs1" value="zero" checked>zero
<input type="radio" name="rs1" value="one">one
<input type="radio" name="rs1" value="two">two
<input type="checkbox" name="cb1" value="cb 1">cb 1
<input type="checkbox" name="cb2" value="cb 2">cb 2
<input type="checkbox" name="cb3" value="cb 3">cb 3
<input type="button" value="Show checked radio value" onclick="
<input type="button" value="Show all checked values" onclick="
<input type="reset">

<script type="text/javascript">

function showRadioChecked(rSet)
var i = rSet.length;
if (rSet[i].checked) return rSet[i].value;

function showAllChecked(f)
var el, els = f.elements;
var x = '';
var i = els.length;
el = els[i];
if (el.checked){
x += '\n' + el.type + ': ' + el.value;
return x;
LVL 53

Accepted Solution

Dhaest earned 500 total points
ID: 33634111
I'll do it in parts. (example in, data coming from access)

1. Fill the checkboxList with the id and dname
    'Use a string variable to hold the ConnectionString.
    Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                "Data Source=C:\File Databases\NWIND.MDB"

    'Create an OleDbConnection object,
    'and then pass in the ConnectionString to the constructor.
    Dim cn As OleDbConnection = New OleDbConnection(connectString)

    'Open the connection.

    'Use a variable to hold the SQL statement.
    Dim selectString As String = "SELECT ID, dname FROM YourTable"

    'Create an OleDbCommand object.
    'Notice that this line passes in the SQL statement and the OleDbConnection object.
    Dim cmd As OleDbCommand = New OleDbCommand(selectString, cn)

    'Send the CommandText to the connection, and then build an OleDbDataReader.
    'Note: The OleDbDataReader is forward-only.
    Dim reader As OleDbDataReader = cmd.ExecuteReader()

         CheckBoxList1.Items.Add(new ListItemreader("dname").ToString(), ListItemreader("ID").ToString())         
    End While

    'Close the reader and the related connection.

Open in new window

LVL 53

Expert Comment

ID: 33634116
2. Retrieve all the values back

' Iterate through the Items collection of the CheckBoxList
         ' control and display the selected items.
         Dim i As Integer

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

            If checkboxlist1.Items(i).Selected Then

               Message.Text &= checkboxlist1.Items(i).Value & "<br />"

            End If


Open in new window

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.


Author Comment

ID: 33635012
no it is not what exact I want I am using SQl server 2005 and ASP.Net(c#)

Author Comment

ID: 33660034
...... good .........
LVL 53

Expert Comment

ID: 33660040
Did you get any progress with my comments ?

Author Closing Comment

ID: 33660069
LVL 53

Expert Comment

ID: 33660084
If it's good, why only a B-grade ?

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Display Day name if condition is true in crystal report (VB.Net) 2 35
Begin Transaction 12 25
Migrate SQL 2005 DB to SQL 2016 4 28
SQL Query 20 19
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

732 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