Arya Chatterjee

Arya Chatterjee

  • NA
  • 1
  • 1.6k

Populate a List from another one

Apr 4 2011 6:11 PM

Hi All,

I am a noobie to C Sharp, so I am not sure what I am even looking for. Or whether my lists approach is even the best way. But here is the question:

I have two lists

List1
Op  | E/R  | Header
AA    EE     A A
BB    RR     B B
CC    EE     C C
DD    EE     D D

List2
LOC | OP |  EE    |  RR    |  TXT1   | TXT2 | TXT3 | TXT4
BBB   AA    XXX      YYY  
BBB   AA    X1X      YY
BBB   BB    PPP      QQQ   
BBB   DD    EEE      FFF  
 

Now, I have to do the following:
For each in List2, look at the OP. Select that OP from List1. If it is EE (in E/R), then take the corresponding EE column from List2, (e.g. XXX for row 1), and populate that text into TXT1. Next, if OP is BB, take data from RR, and put it in TXT2 and so on.
AA corresponds to TXT1, BB to TXT2 and so on..
There are N TXT1, TXT2 etc columns, and N = List1.Count.

So finally, the List should look like:
LOC |  TXT1    | TXT2 | TXT3 | TXT4
BBB    XXX,X1X   QQQ    EEE    
    
What is the best way to do this?

Really appriciate your time and your help.
Arya



Answers (1)