I'm retrieving data pulled from SQL via an XML feed from my website, and each item has an id, name, description which is stuck into an ArrayList, which is then added to an overall ArrayList - this basically represents the rows retrieved from my database.

i.e.

catArray = new ArrayList();
catArray.Add(cat_id);
catArray.Add(cat_name);
catArray.Add(cat_desc);

AllCategories.Add(catArray);

So Q1) I kindof feel this arraylist of arraylists is not the right way to do it, but am a bit unsure how else to contain all this info. enums? keep it as separate id, name and desc arraylists? make a datatable?

Next I need to display the info; basically a list of hyperlinked category names which I can assign a click event to and load info on that particular category. This seems fantastically simple but I am struggling with it.

So Q2) I've sort of got this to work by adding into a listbox, but really I want separate links added into a stackpanel. How would I set this up? Make custom controls?

Thanks.

Recommended Answers

All 2 Replies

First of all I'd suggest to use List<T>.

public class Category
 {
     public int ID {get;set;}
     public string Name {get;set;}
     public string Description { get;set;}
 }

Create a List<Category>.

List<Category> list=new List<Category>();

list.add(new Category()
         {
            ID=cat_id,
            Name=cat_name,
            Description=cat_desc
          });

That's great thanks, I have sorted the linking bit now so this should help me clean up the data a bit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.