473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Arraylist only display last item

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

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


Feb 13 '06 #1
2 1758
ur field values are shared, they shoudln't be.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"David Lozzi" <Da********@nospam.nospam> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
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

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

Feb 13 '06 #2
DUH! Thank you!!

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

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
ur field values are shared, they shoudln't be.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"David Lozzi" <Da********@nospam.nospam> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
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

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


Feb 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my...
3
by: Adam | last post by:
Hi all, I have an arraylist filled with 4 objects and defined as shown below. ArrayList items = new ArrayList(); public Item GetItemAt(int index) { return (Item)items; }
3
by: Celine | last post by:
is it possible to pass an arraylist from one page to another page? If yes how? (I'm using asp.net and c#)
3
by: JJ | last post by:
Hi, I have created an Arraylist object from an Arraylist class. I added rows to the arraylist object and I need to find a particular record in my arraylist. How do I do this? Also if I was in...
9
by: Leon | last post by:
I have a webform in which when the user press generate button the form generate six unique ramdon numbers, the user can also type these six numbers in manually in any order. however, the user can...
12
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns...
6
by: GrandpaB | last post by:
While writing this plea for help, I think I solved my dilemma, but I don't know why the problem solving statement is necessary. The inspiration for the statement came from an undocumented VB...
5
by: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
3
by: carlos123 | last post by:
Ok, im having EXTREME problems, with arraylists, i simply dont understand them, yes i have read your article. Would someone just take a look at this code, i know it sucks. Look at the areas that say...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.