Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 12th, 2008, 10:44 AM
Authorized User
 
Join Date: Jul 2007
Location: Austin, Texas, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default ArrayList

I've read, in several different websites, that one can put any object into an ArrayList. Does this include an ArrayList? Is it possible to have an ArrayList of ArrayLists? I've not tried yet to build my solution with it set up this way. I would like to find out from any of you 'experts' first, before I go through a lot of trouble attempting to make it work if it is not supposed to work.

RLELLE
__________________
RLELLE
  #2 (permalink)  
Old February 12th, 2008, 10:54 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Yes you can do that something like this will work:

        ArrayList ar = new ArrayList();
        ArrayList ar2 = new ArrayList();
        ar2.Add("foo");
        ar.Add(ar2);

        ArrayList ar3 = (ArrayList)ar[0];
        Response.Write(Convert.ToString(ar3[0]));

foo is wrote to the screen. You could also use a List<T> for this secnario.

hth.


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #3 (permalink)  
Old February 12th, 2008, 11:20 AM
Authorized User
 
Join Date: Jul 2007
Location: Austin, Texas, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your prompt reply.

Below is what I am attempting. Does it make sense?

public ArrayList alRvwrNm = new ArrayList();
public ArrayList alActCnt = new ArrayList();
public ArrayList alPrfrNm = new ArrayList();
public ArrayList alDdoCd = new ArrayList();
public ArrayList alGridview = new ArrayList();

alGridview.Add(alPrfrNm, alDdoCd, alActCnt, alRvwrNm);

I am collecting data from three different tables. The data I am collecting is to be be sorted, then posted to a gridview. I had it all on a gridview already, but the column that I needed to sort was a template field. I soon discovered that a template field could not be sorted. So, I had to resort to building and combining these arrays, sorting the data, then posting it to the gridview.

RLELLE
  #4 (permalink)  
Old February 12th, 2008, 11:35 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Add() only takes one argument. The above code will throw an error telling you as much.

I am curious, why are you using an ArrayList as opposed to an ObjectDataSource or SQL Datasource? This seems like alot of work for something so trivial.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #5 (permalink)  
Old February 12th, 2008, 03:38 PM
Authorized User
 
Join Date: Jul 2007
Location: Austin, Texas, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am converting an application written in java over to C#. The programmer that wrote the app in java says he gathered all this data into arrays, sorted the data, then presented it on a form. I am trying to mimic that, but honestly, I do wonder if I could gather up all this data into a dataset, do the sorting, then bind to a gridview. The problem is that the data gathering is a two or three step process. So, storing the data into arrays seemed reasonable. Like I said earlier, I had all this working just fine with a gridview except for the fact that it was not sorted. The column to be sorted was a template field, and the gridview did not like me sorting on that.

RLELLE
  #6 (permalink)  
Old February 12th, 2008, 04:05 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

That doesn't seem to make sense. I declare my SortExpressions in the TemplateField and do not have a problem with this? Are you sure you have set up your sorting correctly? Check out Scott Gu's page, it may shed some light on your problem:

http://weblogs.asp.net/scottgu/archi...11/437995.aspx


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList sort collie C# 1 August 28th, 2007 08:08 AM
ArrayList with UserControl rhd110 General .NET 2 August 12th, 2007 12:29 PM
ArrayList Problem erictamlam C# 2005 3 May 12th, 2007 10:04 AM
Help with an arraylist crazy-nun General .NET 4 July 14th, 2005 03:32 AM
ArrayList kobystud C# 4 May 25th, 2004 02:05 PM



All times are GMT -4. The time now is 10:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.