473,394 Members | 2,071 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,394 software developers and data experts.

Displaying Contents of ArrayList

I have an ArrayList which stores x number of "Policy" objects, where x is
the number of rows returned from a earlier SQL query (therefore it is
changeable).

Each "Policy" has a few methods within it that returns values.

How do I display a row of information for each "Policy" (stored in the
ArrayList) in the browser?

Also, what is the best way of assigning values returned from object methods
to specfic fields in DataLists, DataGrids etc?
Nov 17 '05 #1
2 2290
I have never actually done this before, but from what I understand, you can
add databindings to the datagrid databindings collection. Each databinding
binds the value of a property in your Policy objects to a column in the
datagrid.

In order to do this, your collection must implement the IList interface,
which the ArrayList does.

"Beza" <be**@beza.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
I have an ArrayList which stores x number of "Policy" objects, where x is
the number of rows returned from a earlier SQL query (therefore it is
changeable).

Each "Policy" has a few methods within it that returns values.

How do I display a row of information for each "Policy" (stored in the
ArrayList) in the browser?

Also, what is the best way of assigning values returned from object methods to specfic fields in DataLists, DataGrids etc?

Nov 17 '05 #2
Regarding the array list, try: (and this will be long-hand, there are
plenty of places to take short cuts, but I'm doing it long hand to
show you the steps)

object[] policies = ArrayListofPolicies.ToArray();
// hashed out - this might be ordered, not sure.
foreach( object o in policies ){
Policy p = (Policy)o;
string txt = p.Method1() + "\t";
txt += p.Method2();
txt += p.Method3();
txt += p.Method4();
Console.WriteLine( txt );
}

//or indexed in order:
for( int x=0; x<policies.Length; x++ ){
Policy p = (Policy)policies[x];
string txt = p.Method1();
// .......
Console.WriteLine( txt );
}

Again, this is sloppy long-hand, but I think you get the gist of it.

Also, if you wrote the Policy object and can change it, you might want
to expose the "pieces of information" as an array of values.

for( int x=0; x<policies.Length; x++ ){
Policy p = (Policy)policies[x];
string txt = "";
for( int y=0; y<p.Values.Length; y++ ){
txt += p.Values[x] + "\t";
}
Console.WriteLine( txt );
}

or with a class indexer:
for( int x=0; x<policies.Length; x++ ){
Policy p = (Policy)policies[x];
string txt = "";
for( int y=0; y<p.ValueCount; y++ ){
txt += p[x] + "\t";
}
Console.WriteLine( txt );
}

There are many options.

"Beza" <be**@beza.com> wrote in message news:<e0**************@TK2MSFTNGP11.phx.gbl>...
I have an ArrayList which stores x number of "Policy" objects, where x is
the number of rows returned from a earlier SQL query (therefore it is
changeable).

Each "Policy" has a few methods within it that returns values.

How do I display a row of information for each "Policy" (stored in the
ArrayList) in the browser?

Also, what is the best way of assigning values returned from object methods
to specfic fields in DataLists, DataGrids etc?

Nov 17 '05 #3

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

Similar topics

2
by: Fieldmedic | last post by:
I'm attempting to get an arraylist to display in a Listbox (listbox2). The arraylist is created from selections in a different listbox (listbox1). The 1st listbox has a selection mode of...
2
by: Beza | last post by:
I have an ArrayList which stores x number of "Policy" objects, where x is the number of rows returned from a earlier SQL query (therefore it is changeable). Each "Policy" has a few methods...
1
by: Denis Briel | last post by:
hi everyone, i have a minor prob and am not sure how to solve this. What are we coming from? Well, there are several template files inside a folder. these template files have different names,...
4
by: Christiaan | last post by:
Hi, I have two classes, Department and Employer, the Department contains an ArrayList (employers) filled with Employer objects. I want to display an ArrayList filled with Department objects using...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
0
by: Urs Eichmann | last post by:
As some of you have certainly noticed, due to a flaw in the VS.NET 2003 debugger it is no longer possible to see the contents of a SortedList in the QuickWatch (or the regular watch) window when...
11
by: pmclinn | last post by:
I have a function that returns an arraylist. I want the returned arraylist to be copied into the local arraylist. What is the most efficient way of doing this? -Peter
2
by: ankita | last post by:
Hello, i am using Asp.net application to read contents of FTP folder. I just want to have names of all folders/files that are inside FTP directory. So for that i don't want to download any...
2
by: Picqua | last post by:
I'm having trouble with a class that accepts an ArrayList as a parameter. The code looks something like this: ArrayList arrayOne = new ArrayList(); arrayOne.Add("Hello ");...
2
by: Gangreen | last post by:
hi, I have an arrayList in my program that I want to display in a Jlist. I need the JList to update his contents when the elements in the arraylist change/ an element is added/deleted/... I'm...
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: 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: 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
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
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
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...

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.