Use Rows from a DataTable to Create Columns In oth
Use Rows from one DataTable to Create Columns In another!!!
Hello experts,
I have two datatables
DataTable dtblAuthors = dtblAuthors ( "Authors " )
DataTable dbtlBooks = dbtlBooks ("Books")
I need to add columns to DataTable dtblAuthors like so
dcolCloumn = new DataColumn( "Book1" )
dtblAuthors.columns.add(dcolCloumn )
dcolCloumn2 = new DataColumn( "Book2" )
dtblAuthors.columns.add(dcolCloumn2 )....E.T.C
The twist here is that I need to accomplish this by adding the columns to DataTable dtblAuthors using rows from DataTable dbtlBooks.
so DataTable dtblAuthors could have the following fields;
ID AUTHORNAME
1 John Doe
2 Jane Block
3 Just Wright
and DataTable dbtlBooks could have the following fields
ID BOOKNAME AUTHORID
1. C#.NET 1
2. ASP.NET 1
3. FLASH 1
4. C++ 2
5 DESIGN 3
6. PERL 2
Essentially, where dbtlBooks.AUTHORID = dtblAuthors.AUTHORID I want to create a BOOKNAME column in dtblAuthors to a maximum of six columns.
DEFAULT VALUE = NONNE
So my resulting DataTable would be;
ID AUTHORNAME BOOK1 BOOK2 BOOK3 BOOK4 BOOK5 BOOK6
1. John Doe C#.NET ASP.NET FLASH NONNE NONNE NONNE
2. Jane Block C++ PERL
3. Just Wright DESIGN
NONNE<---------IS THE DEFAULT VALUE IF THERE ISN'T A BOOK FOR THE COLUMN
how do I accomplish this?
thankx
|