Displaying Contents of ArrayList

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. ArrayList error
      My flash application sends a parameter to CF with something like getImageList(S2123_1) My getImageList.cfm includes the line <cfset areaId =...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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...
    > 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?
    >
    >

    craig Guest

  4. #3

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139