D
David Lozzi
Hello,
I have an arraylist that loads a checkboxlist. I populate the arraylist
using a custom class and pulling the data from the web.config file. When the
checkboxlist is loaded, only the last item in the list is displayed for each
item, in other words, item #4 is displayed 4 times. My code is below.
Thanks
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
LoadHire()
End If
End Sub
Sub LoadHire()
Dim opts() As String =
ConfigurationSettings.AppSettings("HireSelection").Split(";")
Dim chks As New ArrayList
For i As Integer = 0 To opts.Length - 1
Dim opt As New NewHire(opts(i), opts(i))
chks.Add(opt)
Next
chkForHire.DataSource = chks
chkForHire.DataBind()
End Sub
Public Class NewHire
Private Shared _val As String = [String].Empty
Private Shared _text As String = [String].Empty
Public Property DataValue1() As String
Get
Return _val
End Get
Set(ByVal Value As String)
_val = Value
End Set
End Property
Public Property DataText1() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
Public Sub New(ByVal val As String, ByVal txt As String)
Me._val = val
Me._text = txt
End Sub
End Class
I have an arraylist that loads a checkboxlist. I populate the arraylist
using a custom class and pulling the data from the web.config file. When the
checkboxlist is loaded, only the last item in the list is displayed for each
item, in other words, item #4 is displayed 4 times. My code is below.
Thanks
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
LoadHire()
End If
End Sub
Sub LoadHire()
Dim opts() As String =
ConfigurationSettings.AppSettings("HireSelection").Split(";")
Dim chks As New ArrayList
For i As Integer = 0 To opts.Length - 1
Dim opt As New NewHire(opts(i), opts(i))
chks.Add(opt)
Next
chkForHire.DataSource = chks
chkForHire.DataBind()
End Sub
Public Class NewHire
Private Shared _val As String = [String].Empty
Private Shared _text As String = [String].Empty
Public Property DataValue1() As String
Get
Return _val
End Get
Set(ByVal Value As String)
_val = Value
End Set
End Property
Public Property DataText1() As String
Get
Return _text
End Get
Set(ByVal Value As String)
_text = Value
End Set
End Property
Public Sub New(ByVal val As String, ByVal txt As String)
Me._val = val
Me._text = txt
End Sub
End Class