Results 1 to 7 of 7

Thread: [2005] Binding two tables into DataGridView

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    150

    [2005] Binding two tables into DataGridView

    If I have two tables that I want to bind into one DataGridView , how do I achieve that ?

    Let's say I have two tables , one table has car colors (COLOR_ID,COLOR_TITLE) and the second table has (CAR_ID,CAR_TITLE,COLOR_ID) , The red color represents the primary key and the foreign key in the tables.

    I know how bind one table to a DataGridView but when this table has foreign key , I don't know how to get their values and display the value in the DataGridView

    HELP ?

  2. #2
    Hyperactive Member
    Join Date
    Jul 2007
    Location
    Iowa
    Posts
    298

    Re: [2005] Binding two tables into DataGridView

    Where are you storing your data? What kind of database? ex SQL, Access
    Tuber

    "I don't know the rules"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    150

    Re: [2005] Binding two tables into DataGridView

    Access Database

    I know how to bind one table though , but not two tables into one DataGridView

    I know it's possible by changing the field to dropdown list and modifying the databinding options , but I don't want a drop down list . .
    Last edited by bomayed; Aug 29th, 2007 at 02:04 PM.

  4. #4
    Hyperactive Member
    Join Date
    Jul 2007
    Location
    Iowa
    Posts
    298

    Re: [2005] Binding two tables into DataGridView

    I don't know much about Access, I use a SQL database and I just create a view when I want to do that.
    Tuber

    "I don't know the rules"

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    150

    Re: [2005] Binding two tables into DataGridView

    Ok , that's exactlly what I was looking for thanks

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    150

    Re: [2005] Binding two tables into DataGridView

    I've craeted a view , now I'm stuck , how do I bind this view to a DataGridView?

  7. #7
    Hyperactive Member
    Join Date
    Jul 2007
    Location
    Iowa
    Posts
    298

    Re: [2005] Binding two tables into DataGridView

    Quote Originally Posted by bomayed
    I've craeted a view , now I'm stuck , how do I bind this view to a DataGridView?
    Create an Adapter, Find your "View" Select whatever data you want from it. Then generate a dataset, either a new one or use an existing. This will add your view to the dataset then when creating a custom DataGridView call your "View" in the dataset your created.

    I'm not that experienced so this could be wrong. I still use the old grid and do a table style, which is probably obsolete.

    Code:
    Private Sub Create_Resume_Datagrid()
            DataGrid2.TableStyles.Clear()
            Dim grdTableStyle2 As New DataGridTableStyle()
    
            With grdTableStyle2
                .MappingName = Me.DsAppResInt1.Tables("vw_AppResumes").TableName
                .BackColor = System.Drawing.Color.White
                .ReadOnly = True
                .AllowSorting = True
                .RowHeadersVisible = True
            End With
    
            Dim intDefaultColLen As Integer = (DataGrid1.Width) / 7
    
            Dim grdColStyle0 As New DataGridTextBoxColumn()
            With grdColStyle0
                .MappingName = "Resume_Unique"
                .HeaderText = "unique"
                .Width = 0
            End With
    Tuber

    "I don't know the rules"

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