المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Populating a Treeview from a dataset in c#



C# Programming
01-24-2010, 04:40 AM
Okay, I'm still fairly new to the whole c# coding world so please don't beat me up too bad.
I was wondering if someone could shed some light on me with how I would go about doing the following..

I have a database setup to keep track of my books and I wanted to make a treeview to list the authors and then each book that I have by that author. Well lets say I have 4 books for the example

Database consist of ID, Author, Title


row 1 : 1, Tony Stegall, First book
row 2 : 2, Joe Smith, Joe Says Hi
row 3 : 3, Tony Stegall, Second book
row 4 : 4, Jim Smith, Jim has a friend named Joe

How in the heck can i get it to print out something like this

Smith,Jim
- Jim has a friend named Joe
Smith,Joe
- Joe Says Hi
Stegall, Tony
- First Book
- Second Book


Would I have to run a filter on each authorname? Or is there some other way to do this? Just trying to learn this stuff but not really sure how to go about it. I pretty much understand the whole treeview add a parent then add a child deal but I'm not sure how to get the childs to be placed under the unique parent...


Thanks for your help.