[ I am using VS2005 c# ]
Hello,
I am looking for a description how to use lookup binding in accordance
with a DataGridViewColumn.
I found a nice article about "lookup binding", but i does not use a
DataGridView.
Article
=> Ari Roth's Blog => "Complex Binding and Lookup Binding"
=>
http://blogs.msdn.com/ariroth/archive/2005/01/21/358478.aspx ----------------
MORE PRECISELEY
I have a DataGridView which is bound to a DataTable by an BindingSource.
--------
myBindingSource.DataSource = myDataTable_parent;
myDataGridView.DataSource = myBindingSource;
--------
I have two DataTables with these columns:
1) Table => myDataTable_parent ( Name := dtParent )
Columname => ID
Columname => jobtypeID
Columname => some other columns
"jobtypeID" is a foreign-key that relates to the ID-Column of the table
"myDataTable_jobtypeDetails"
2) Table => myDataTable_jobtypeDetails ( Name := dtJobdetails )
Columname => ID
Columname => jobtypename
--------
--------
Analogical to the article mentioned above I tried the following:
=> create a DataSource
=> Add the 2 DataTables and a DataRelation to the DataSet
=> Add a Binding to the DataGridView
--------
myDataset.Tables.Add(myDataTable_parent);
myDataset.Tables.Add(myDataTable_jobstatusDetails);
myDataset.Relations.Add( new DataRelation ("jobtypesRel",
myDataTable_parent["jobtypeID"], myDataTable_jobtypesDetails["ID"]);
myDataGridView.DataBindings.Add("jobtypeID", myDataSet,
"dtJobdetails.jobtypesRel.ID");
--------
--------
PROBLEM
An Argument exception with the following test is thrown during Runtime:
"Cannot bind to the property 'DataGridViewTextBoxColumn {
Name=jobtypeID, Index=0 }' on the target control.
Parameter name: PropertyName"
--------
--------
QUESTION
Can someone give me a description howto Bind a DataGridViewTextBoxColumn
to an DataRelation?
Or another way to resolve the jobtypeID to the jobtypeName?
--------
--------
Thank you for your time.
Greetings Gordian