473,503 Members | 11,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Arraylist Items to an asp table. Please help me

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 clicked I want the array item added to the asp table and all
preceeding clicks id like the rows underneath added with the next array
value.
Sorry finding this hard to explain but hope you know what I mean.

Below might give you an idea of what im looking for. On the first click id
like the arraylist value added to the asp table like so

Table Addresses(asp table)
11 Add, 11 City, 11Postcode

On the next click id like the 2nd element of the array to be added like so

Table Addresses(asp table)
11 Add, 11 City, 11 Postcode
22 Add, 22 City, 22 Postcode

etc, etc

So Im basically looking to display each item of the Array one by one
underneath each other in the asptable.

Is anyone able to help me with this?? im going crazy trying to work it out!!
Thanks in advance for anyone that can help me further with this problem.

The CODE I HAVE TO DATE ARE AS FOLLOWS: Code behind page

private ArrayList addresses;

private void Page_Load(object sender, System.EventArgs e)
{
if(!(ViewState["Addresses"]==null))
{
this.addresses = (ArrayList)ViewState["Addresses"];
}
else
{
this.addresses = new ArrayList();
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
//add addresses to the arraylist
if(this.TextBox1.Text.Length > 0)
{
addresses.Add(this.TextBox1.Text.ToString()+","+
this.TextBox2.Text.ToString() + ", " + this.TextBox3.Text.ToString() +
","+this.TextBox4.Text.ToString() + ", " + this.TextBox5.Text.ToString() + ",
" + this.TextBox6.Text.ToString()); }

//Clear the Address items textboxes
this.TextBox1.Text = "";
this.TextBox2.Text = "";
this.TextBox3.Text = "";
this.TextBox4.Text = "";
this.TextBox5.Text = "";
this.TextBox6.Text = "";

//display the search addresses in the label
IEnumerator enumerator = addresses.GetEnumerator();
System.Text.StringBuilder buffer = new System.Text.StringBuilder();
while (enumerator.MoveNext() )
buffer.Append(enumerator.Current + "\n" );
Label1.Text = buffer.ToString();

//Loop through to display what we are searching on
System.Text.StringBuilder _oOutput = new System.Text.StringBuilder();
for(int i = 0; i < addresses.Count; i++)
{
_oOutput.Append((string)addresses[i]);
_oOutput.Append("\n");
}
// ******would like to be able to loop through the addresses added to the
array list and populate the labels in my asp table. The code for me asp
table is below*********
//lblAddress1.Text = _oOutput.ToString();
}

Here is the asp table I have in the html code: -
<asp:table id="tblSearchAddresses" Width="100%" BackColor="#00C0C0"
BorderColor="Yellow" Runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server" ID="lblAddress1"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server" ID="lblAddress2"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server" ID="lblAddress3"></asp:Label>
</asp:TableCell>
</asp:TableRow>
etc.......
</asp:table>
Nov 22 '05 #1
0 1656

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...
6
1803
by: Stephen | last post by:
Im trying to carry work out an else if clause in the below method but i'm having a lot of difficulty getting the correct code which allows me to check and see if an arraylist items has text in it...
1
3985
by: Jax | last post by:
I have an arraylist of objects. This arraylist is bound to a repeater. That repeater then creates a set of controls like so <asp:repeater id="garmentRepeater" runat="server"...
11
33453
by: paradox | last post by:
Basically I have an ArrayList of strings; I need a fast way of searching through and comparing the elements of the ArrayList and the return an ArrayList of items that have 3 Duplicates. For...
4
5449
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
6
10782
by: Maheshkumar.R | last post by:
How i can store images in array @ runtime..? What are the possbile ways.. Thankz.. - Mähésh Kumär. R
2
2421
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
5
2358
by: Extremest | last post by:
Is there a way to add new items to an arraylist witht he indexer? like with a normal array I can just do like array = new. What I have read with arraylist it will throw an exception if I try to...
4
2525
by: Rob Meade | last post by:
Hi all, I played with my first bit of AJAX the other week and was pleasantly surprised that I achieved my goal..now I'd like to try something else.. Question... If I have an updatePanel,...
8
2580
by: Guy | last post by:
Is there a better way to search identical elements in a sorted array list than the following: iIndex = Array.BinarySearch( m_Array, 0, m_Array.Count, aSearchedObject ); aFoundObject= m_Array;...
0
7207
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
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
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...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
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 ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
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...

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.