473,804 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
LoadHire()
End If
End Sub

Sub LoadHire()
Dim opts() As String =
ConfigurationSe ttings.AppSetti ngs("HireSelect ion").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.Data Source = chks
chkForHire.Data Bind()
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 1779
ur field values are shared, they shoudln't be.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"David Lozzi" <Da********@nos pam.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP10.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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
LoadHire()
End If
End Sub

Sub LoadHire()
Dim opts() As String =
ConfigurationSe ttings.AppSetti ngs("HireSelect ion").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.Data Source = chks
chkForHire.Data Bind()
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******** ********@tk2msf tngp13.phx.gbl. ..
ur field values are shared, they shoudln't be.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"David Lozzi" <Da********@nos pam.nospam> wrote in message
news:%2******** *******@TK2MSFT NGP10.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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
LoadHire()
End If
End Sub

Sub LoadHire()
Dim opts() As String =
ConfigurationSe ttings.AppSetti ngs("HireSelect ion").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.Data Source = chks
chkForHire.Data Bind()
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
464
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 asp table. The asp table has numerous rows and each row has a label item within it. Im finding it impossible to get something to work which adds the newest item in the array list to the next row in the asp table. the first time the button is...
3
1979
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
2061
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
3759
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 the middle of building the arraylist and wanted to call the last record added to arraylist object how can I do this? Thanks,
9
1416
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 also press a post button that post these six numbers into the database. My problem is that these six numbers need to be posted to the database from less to greatest, and all of my code is within the business tier class not the code behind class. ...
12
6756
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 True. Therefore, overriding the Equals method in the class definition of the items I put in the ArrayList should make the IndexOf method use my version of the Equals method?!
6
1466
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 example I found on the web. I would be most appreciative if someone could explain why this statement is necessary and what does it do: MyArt = New Art
5
2437
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 entry and you select another index it goes boom!!!. Funny thing is the SelectedIndex Changed routine fires off perfectly and then crash after the return from this code. Now looking around the news groups it appears to be a bug in the .net...
3
1753
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 "HELP!!!" next to them. But basicly i want to take data from textfields and put them into an arraylist. So the user inputs data, name, address, age all that, hits save (This is when it goes into the arraylist) the textfields clear, and they are ready...
0
10338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.