|
-
Aug 29th, 2007, 01:38 PM
#1
Thread Starter
Addicted Member
[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 ?
-
Aug 29th, 2007, 01:40 PM
#2
Hyperactive Member
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"
-
Aug 29th, 2007, 02:01 PM
#3
Thread Starter
Addicted Member
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.
-
Aug 29th, 2007, 02:03 PM
#4
Hyperactive Member
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"
-
Aug 29th, 2007, 02:13 PM
#5
Thread Starter
Addicted Member
Re: [2005] Binding two tables into DataGridView
Ok , that's exactlly what I was looking for thanks
-
Aug 30th, 2007, 02:55 AM
#6
Thread Starter
Addicted Member
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?
-
Aug 30th, 2007, 11:48 AM
#7
Hyperactive Member
Re: [2005] Binding two tables into DataGridView
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|