Solved

Save Multiple Check Box Values

Posted on 2006-10-31
6
271 Views
Last Modified: 2010-04-23
I am trying to figure out take any or all of the values in a checkbox list that have been selected, convert them to a string and save them in a database.

I can do the below code, but this only saves (1) value.

txtWorkShedule.text = CheckBoxList1.SelectedItem.ToString

WannaBGeek
0
Comment
Question by:WannaBGeek
6 Comments
 
LVL 8

Expert Comment

by:razo
ID: 17842438
    For i = 0 To CheckedListBox1.CheckedIndices.Count - 1
txtWorkShedule.text +=" " +CheckedListBox1.CheckedIndices.Item(i).tostring
next
0
 
LVL 12

Expert Comment

by:Mamtha1982
ID: 17842512
0
 
LVL 12

Expert Comment

by:Mamtha1982
ID: 17842609
sorry , razo is right.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Accepted Solution

by:
Mamtha1982 earned 500 total points
ID: 17842642
if you want Text from the selection item, you can do

For i = 0 To CheckedListBox1.CheckedItems.Count - 1
txtWorkShedule.Text +=" " +CheckedListBox1.CheckedItems(i)
Next
0
 

Author Comment

by:WannaBGeek
ID: 17842675
Thank you Mamtha!

This is my finished code it works perfectly! :)

Protected Sub CkSchedule_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CkSchedule.SelectedIndexChanged
        Dim strchklist As String = ""
        Dim li As ListItem
        For Each li In CkSchedule.Items
            If li.Selected Then
                strchklist += li.Text + ", "
            End If
        Next
        txtWorkSched.Text = ((strchklist))
0
 
LVL 3

Expert Comment

by:vsvb
ID: 17842719
try this
        Dim itemChecked As Object
        Dim Str As String
        For Each itemChecked In CheckedListBox5.CheckedItems
            Str += "" + itemChecked.ToString
        Next
        MsgBox(Str)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now