Ask a Question related to ASP.NET General, Design and Development.
-
Beza #1
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?
Beza Guest
-
ArrayList error
My flash application sends a parameter to CF with something like getImageList(S2123_1) My getImageList.cfm includes the line <cfset areaId =... -
Listing contents of a directory folder to contents ofdirectory
cfdirectory listing... Here is my problem... I am listing directorys and when each directory is listed I want to list the contents of that... -
Repeater and ArrayList
Hi, I am trying to use arraylist (of strings) as Datasource for a repeater. what do I write in item template? DataBinder.Eval....??? The list... -
ArrayList and datagrid
Hello, I have a problem to bind my arrayList to a datagrid. I have read the article on MSDN but I dont ' understand where is the bug. I have 2... -
Arraylist and datatable
I want to take a collection of objects in an Arraylist and turn them into a datatable so I can set it equal to a dataview. I want to use the... -
craig #2
Re: Displaying Contents of ArrayList
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" <beza@beza.com> wrote in message
news:e0Xn5ciRDHA.2196@TK2MSFTNGP11.phx.gbl...methods> 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> to specfic fields in DataLists, DataGrids etc?
>
>
craig Guest
-
Chris Hornberger #3
Re: Displaying Contents of ArrayList
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" <beza@beza.com> wrote in message news:<e0Xn5ciRDHA.2196@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?Chris Hornberger Guest



Reply With Quote

