Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

Arraylist only display last item

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Lozzi - 13 Feb 2006 17:51 GMT
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

Signature

David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

Karl Seguin [MVP] - 13 Feb 2006 18:03 GMT
ur field values are shared, they shoudln't be.

Karl

Signature

http://www.openmymind.net/
http://www.fuelindustries.com/

> Hello,
>
[quoted text clipped - 54 lines]
>    End Sub
> End Class
David Lozzi - 13 Feb 2006 18:07 GMT
DUH! Thank you!!

Signature

David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

> ur field values are shared, they shoudln't be.
>
[quoted text clipped - 58 lines]
>>    End Sub
>> End Class

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.