Solved

Save Multiple Check Box Values

Posted on 2006-10-31
6
296 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
[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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with preventing selection from a combobox 11 41
VB.Net. Reading xml value 6 38
How to repeat the data 4 30
vb.net deleting excel sheet in workbook 11 34
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…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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