JanAntwerpen
Member
- Joined
- Nov 5, 2013
- Messages
- 8
- Programming Experience
- Beginner
Hello,
I have problems with a comboboxcolumn in a datagridview: As I want to insert a new row, I get a "System.ArgumentException: The value of the DataGridViewComboBoxCell is invalid." I am using Linq to SQL to populate the data from different tables:
- Table Customer (ID (key), Name,...)
- Table Address (ID (key), CustomerID, Street,...)
- Table ContactPerson (ID (key), AddressID, Name, Title,...)
My Linq query to populate the ContactDataGridView(which is bound to the TextBox RelationIdTextBox), is following:
This works fine.
In this ContactDataGridView I have a ComboBoxCell AddressID which populates the streetnames instead of the AddressID, using following linq query:
This works fine as well.
That is, untill I want to add a new row in this datagridview. Then I get the error "System.ArgumentException: The value of the DataGridViewComboBoxCell is invalid."
Can anyone help to make me understand what I am doing wrong? I really cannot figure it out!
Thanks!
I have problems with a comboboxcolumn in a datagridview: As I want to insert a new row, I get a "System.ArgumentException: The value of the DataGridViewComboBoxCell is invalid." I am using Linq to SQL to populate the data from different tables:
- Table Customer (ID (key), Name,...)
- Table Address (ID (key), CustomerID, Street,...)
- Table ContactPerson (ID (key), AddressID, Name, Title,...)
My Linq query to populate the ContactDataGridView(which is bound to the TextBox RelationIdTextBox), is following:
C#:
var y = from r in BH.Relations
where r.RelationID.ToString() == relationIDTextBox.Text
join v in BH.Addresss on r.RelationID equals v.RelationID
join c in BH.ContactPersons on v.AddressID equals c.AddressID
select c;
contactPersonsBindingSource.DataSource = y;
ContactDataGridView.DataSource = contactPersonsBindingSource;
In this ContactDataGridView I have a ComboBoxCell AddressID which populates the streetnames instead of the AddressID, using following linq query:
C#:
var addr = from a in BH.Addresss
where a.RelationID.ToString() == relationIDTextBox.Text
select new { AddressID = a.AddressID, Street = a.Street };
ContactAddressBindingSource = addr;
That is, untill I want to add a new row in this datagridview. Then I get the error "System.ArgumentException: The value of the DataGridViewComboBoxCell is invalid."
Can anyone help to make me understand what I am doing wrong? I really cannot figure it out!
Thanks!