How to assign a text to and how to retrieve the values of a CheckboxList in ASP.NET?

Question

How to assign a text to and how to retrieve the values of a CheckboxList in ASP.NET?

Re: How to assign a text to and how to retrieve the values of a

CheckBoxList is almost equivalent to the Listbox web server control. The following example explains how to declare a CheckboxList web server control and how to assign and retrieve values depending upon the values selected by the user.

CheckboxList Web Server Control - by Das

Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)

Dim ctr As Integer
lblResult.Text = "The values for your selection are: "
For ctr = 0 To chkBoxList.Items.Count - 1
If chkBoxList.Items(ctr).Selected Then
lblResult.Text += chkBoxList.Items(ctr).Value & ", "
End If
Next

End Sub



Music
Driving
Boating
Fishing
Eating

 
 

Re: How to assign a text to and how to retrieve the values of a

ListBox1.SelectionMode = ListSelectionMode.Multiple;