Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
(i will try to express my self as much as i can)
I was wondering if i could to add some controls (like labels) in list view doing it with code..
Here is what actually i wanna know (how to):

lats say in our database in some table (lets call it table1) we have two attributes - id1 and name1, then we have table2 with id2 and name2, and we have table3 that would contain the keys from the other two tables (id1, id2)..
then if we would fill the tables we would have something like:
(just an example)

table1             table2           table3
id1   name1        id2   name2      id1 id2
0     USA          0     Michael    0    0      
1     China        1     John       1    0     
2     Japan                         2    0     
3     Russia                        3    0    
                                    0    1    
                                    1    1

(like who has been where)
and when i would to show them in listview, to be something like this:

----------------------------
Name2: Michael
has been in:
USA, China, Japan, Russia 
----------------------------
Name2: John
has been in:
USA, China
----------------------------



In this case in the first row we have 4 records of cities and in the second only 2..

Soo is it possible to do this, or i am shooting in blank?

Thanks in advance..

P.S. If i haven't been clear what i am asking for, tell me i ll try to write it better...
Posted

1 solution

It seems like a Repeater control may be appropriate for you. Specify the template to contain the controls and layout you need. The variability in the countries can be handled by either returning them in a single field from your database query, or business logic. Or add a nested Repeater control to bind them from the database independently
 
Share this answer
 
Comments
Xonfused 30-Nov-11 8:15am    
thank you for the answer, but i have a question.
I like the idea to put them in a single row like in a label, but how could i access the label from the list view? like in this example, i would need to get the label from the itemtemplate of the listview (the label) and in a datareader to write all the cities in the label, But i should also add in the sql command +"Where ID2=(with current row table2 id)"...

I ll look also at repeater control now, since i havent encounter with it so far.. but if there is a solution on the above then better i think.

P.S. when i am writing this i am getting confused from my own text, sorry if i am not understandable, but english isnt my first language (but i hope you do understand me :)..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900