CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2005
    Posts
    3

    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??

  2. #2
    Join Date
    Jul 2010
    Posts
    82

    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???

  3. #3
    Join Date
    Sep 2005
    Posts
    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.

  4. #4
    Join Date
    Sep 2005
    Posts
    3

    Smile 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
  •  





Click Here to Expand Forum to Full Width

Featured