473,385 Members | 1,942 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,385 software developers and data experts.

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 1645

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...
6
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.