Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Star
10850 Points
2098 Posts
Sep 08, 2006 01:37 PM|LINK
How about this.
Partial Class test
Inherits CyrilJohnston.CoreLibrary.WebPage
Dim cbxlist As New CheckBoxList
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
Dim sitems As New System.Collections.Specialized.StringCollection
cbxlist.ID = "dynamicCheckBox"
For i As Integer = 1 To 10
sitems.Add(i.ToString)
Next
cbxlist.DataSource = sitems
Me.PlaceHolder1.Controls.Add(cbxlist)
cbxlist.DataBind()
End Sub
………
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CheckedIndexes As String = ""
Dim CheckedText As String = ""
For i As Integer = 0 To Me.cbxlist.Items.Count - 1
If Me.cbxlist.Items(i).Selected Then
CheckedIndexes &= "Index=" & Me.cbxlist.Items(i).Value & ControlChars.CrLf
End If
' Breakpoint here to view
CheckedIndexes = ""
Rgds,
Martin.
mokeefe
Star
10850 Points
2098 Posts
Re: Selected values from a dynamically created CheckBoxList
Sep 08, 2006 01:37 PM|LINK
How about this.
Partial Class test
Inherits CyrilJohnston.CoreLibrary.WebPage
Dim cbxlist As New CheckBoxList
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
Dim sitems As New System.Collections.Specialized.StringCollection
cbxlist.ID = "dynamicCheckBox"
For i As Integer = 1 To 10
sitems.Add(i.ToString)
Next
cbxlist.DataSource = sitems
Me.PlaceHolder1.Controls.Add(cbxlist)
cbxlist.DataBind()
End Sub
………
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CheckedIndexes As String = ""
Dim CheckedText As String = ""
For i As Integer = 0 To Me.cbxlist.Items.Count - 1
If Me.cbxlist.Items(i).Selected Then
CheckedIndexes &= "Index=" & Me.cbxlist.Items(i).Value & ControlChars.CrLf
End If
Next
' Breakpoint here to view
CheckedIndexes = ""
End Sub
Rgds,
Martin.
Martin.
For the benefit of all users please mark any post answers as appropriate.