|
-
September 28th, 2010, 06:35 AM
#1
binding multiple DataGridView
I am building Windows Form application. I have a 3 tables
table1 (Sr, ProjectNum, OpeningDate, ClosingDate)
table2 (sr, ProjectNum, ItemNum, ItemDescription, ItemQty, ItemPrice)
table3 (sr, ProjectNum, Testing)
As I scroll table1 using ProjectNum, I want to displayed accordingly data from table2 and table3 on screen.
I already have got table1 item as textBox using DataSource window, table2 as DataGridView and table3 as DataGridView.
Now I want to associate textbox field of table1 with DataGridView of table2 and table3.
Say I have project num 12112, now I want to display only records with 12112 project number from table2 and table3.
Any Suggestion please??
-
September 28th, 2010, 03:51 PM
#2
Re: binding multiple DataGridView
Use a query and get the results you want for 12112 -like Select * from xyz where projectnum= "12112" and then set this as datasource to gridviews 2 and 3 appropriately.
You can read the datareader into a datatable and then set it as gridview's datasource.
Datatable dt = dt.load(reader);
gridview2.datasource = dt;
Whats the problem you're facing here???
-
September 29th, 2010, 12:23 AM
#3
Re: binding multiple DataGridView
Thanks for you quick reply.
Actually I don't know how to configure multiple GridView, So I am stuck here.
I just mentioned 12112 as an example. I want to scroll through all the records in table1 with different ProjectNums. and I want to display appropriate records from table2 and table3 in DataGridView like MS Access Northwind sample
Once again appreciate for your help.
-
September 29th, 2010, 04:46 AM
#4
Re: binding multiple DataGridView
I have got done it through DataGridView Property --> Data --> DataSource
then I choose a Foreign key FK_Table2_Table1 and thats it.
Thanks a lot for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|