views:

187

answers:

2

Below code is written in such a way to retrieve all selected check box values

But its retieve only the first selected value

Please help

Dim CheckedValues As String
                For Each item as ListItem In txt_panview0_ddinput1.Items
              If item.Selected Then
                  CheckedValues = CheckedValues & item.Value
             End If
                Next
                If Not String.IsNullOrEmpty(checkedValues) Then
                    checkedValues = checkedValues.Substring(1)
                End If

 tempCollector = tempCollector + "<br>" + "Area Name" + ": " + checkedValues
+1  A: 

If I read your code correctly, you're mashing together all of the values from your list into a string, without anything separating them. You therefore have no way of retrieving the original values.

You could try separating your values with a comma before adding them to the string. But there might be a better way to do this. It really depends on what you are trying to do. You might have better luck filling a list object.

Robert Harvey
I am trying to put the selected values in a checkbox to tempCollector variable , this tempcollector variable value comes the body of the email
i couldnt see any property named multiselect for my checkboxlist
there is no list box in my design view ..
txt_panview0_ddinput1 is not a listbox it is a checkboxlist
A: 

Changed CheckedValues = CheckedValues & item.Value

to

CheckedValues += CheckedValues & item.Value perhaps