dynamically name dynamic arraylists

Discussion in 'ASP .Net' started by drdave@canoemail.com, Dec 8, 2005.

  1. Guest

    I would like to have ten arraylists created within a loop.. is there a
    conversion or something I can do to acheive this..

    pseudo:

    Dim counter As Integer = 0
    Dim ArrName As ArrayList

    '******** LOOP OVER THE VALUES ********************

    For Each y in ProvArrList

    ArrName = ("Arrname") & counter.ToString
    Dim ArrName As New Arraylist ()
    counter = (counter + 1)
    Next

    course this gives me error' Value of type string cannot be converted to
    system.collection.arraylist

    Is there another way to accomplish this??


    tia

    Dave
    , Dec 8, 2005
    #1
    1. Advertising

  2. Why not add them to a Hashtable?

    <> wrote in message
    news:...
    >I would like to have ten arraylists created within a loop.. is there a
    > conversion or something I can do to acheive this..
    >
    > pseudo:
    >
    > Dim counter As Integer = 0
    > Dim ArrName As ArrayList
    >
    > '******** LOOP OVER THE VALUES ********************
    >
    > For Each y in ProvArrList
    >
    > ArrName = ("Arrname") & counter.ToString
    > Dim ArrName As New Arraylist ()
    > counter = (counter + 1)
    > Next
    >
    > course this gives me error' Value of type string cannot be converted to
    > system.collection.arraylist
    >
    > Is there another way to accomplish this??
    >
    >
    > tia
    >
    > Dave
    >
    Peter Rilling, Dec 8, 2005
    #2
    1. Advertising

  3. Guest

    I need to use Arraylists as I need the data in a specific order.. I
    tried using hashtables but the data got all jumbled around.. I tried
    using sortedlists as well but it sorted my data... not the way I
    needed it.. :eek:(

    or can I store my arraylists inside a hashtable.. hmm I had not thought
    of that I'll check it out.. I would have to fill the arraylists before
    adding them to the hashtable..

    I eventually want to bind 10 different repeaters to the arraylists

    thx.
    , Dec 8, 2005
    #3
  4. I mean put the ArrayLists in the Hashtable. For instance.

    pseudocode:

    Create hash table myHT;
    for x = 0 to 10
    {
    Create new array list newList;
    Create key to identify array list (key = "array" + x);
    Add new list to hashtable (myHT.add(key, newList);
    }

    // Now you have all the arrays and each hashtable element is your varaible.

    <> wrote in message
    news:...
    >I need to use Arraylists as I need the data in a specific order.. I
    > tried using hashtables but the data got all jumbled around.. I tried
    > using sortedlists as well but it sorted my data... not the way I
    > needed it.. :eek:(
    >
    > or can I store my arraylists inside a hashtable.. hmm I had not thought
    > of that I'll check it out.. I would have to fill the arraylists before
    > adding them to the hashtable..
    >
    > I eventually want to bind 10 different repeaters to the arraylists
    >
    > thx.
    >
    Peter Rilling, Dec 8, 2005
    #4
  5. Guest

    I'll try that out..

    Thx!!
    , Dec 8, 2005
    #5
  6. Karl Seguin Guest

    If the key is going to be meaningless, why not simply add them to an
    arraylist?

    ArrayList list = new ArrayList(10);
    for (int x = 0; i < 10; ++x)
    {
    list.Add(new ArrayList());
    }

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Peter Rilling" <> wrote in message
    news:etNtQkB$...
    >I mean put the ArrayLists in the Hashtable. For instance.
    >
    > pseudocode:
    >
    > Create hash table myHT;
    > for x = 0 to 10
    > {
    > Create new array list newList;
    > Create key to identify array list (key = "array" + x);
    > Add new list to hashtable (myHT.add(key, newList);
    > }
    >
    > // Now you have all the arrays and each hashtable element is your
    > varaible.
    >
    > <> wrote in message
    > news:...
    >>I need to use Arraylists as I need the data in a specific order.. I
    >> tried using hashtables but the data got all jumbled around.. I tried
    >> using sortedlists as well but it sorted my data... not the way I
    >> needed it.. :eek:(
    >>
    >> or can I store my arraylists inside a hashtable.. hmm I had not thought
    >> of that I'll check it out.. I would have to fill the arraylists before
    >> adding them to the hashtable..
    >>
    >> I eventually want to bind 10 different repeaters to the arraylists
    >>
    >> thx.
    >>

    >
    >
    Karl Seguin, Dec 8, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UG9udGlNYXg=?=

    ArrayList of ArrayLists: How to implement IEnumerable

    =?Utf-8?B?UG9udGlNYXg=?=, Jul 5, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    421
    =?Utf-8?B?UG9udGlNYXg=?=
    Jul 5, 2004
  2. Jim Bancroft
    Replies:
    3
    Views:
    1,866
    Bob Weiner
    May 2, 2005
  3. =?Utf-8?B?RE9UTkVUR1VZ?=

    Comparing two arraylists

    =?Utf-8?B?RE9UTkVUR1VZ?=, Aug 18, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,614
    =?Utf-8?B?VmlqYXlha3Jpc2huYQ==?=
    Aug 24, 2005
  4. standshik
    Replies:
    2
    Views:
    14,730
    N Mulangi
    Feb 11, 2006
  5. Jim Bancroft

    binding ArrayLists to DataGrids-- how to name the columns?

    Jim Bancroft, Apr 30, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    120
    Bob Weiner
    May 2, 2005
Loading...

Share This Page