Click here to Skip to main content
14,830,143 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am trying to update a field in one table using values from another,
i have successfully achieved data binding, if the foreign key is linked to a primary key in the same table, but cannot seem to get it to work on relational tables,

dbs = new dbConnDataContext();

var userGrouping =
  from c in dbs.UserGroupings
  select c;

var group =
    from c in dbs.Groups
    select c;
//this is a data navigation bar
navUserGroupings.DataSource = userGrouping;

groupComboBox.DataSource = group;
groupComboBox.DisplayMember = "GroupName";
groupComboBox.ValueMember = "ID";
groupComboBox.DataBindings.Add("SelectedValue", userGrouping, "GroupID", true, DataSourceUpdateMode.OnPropertyChanged, 0);

Everytime i submit changes, it inserts 0 regardless of the value i select


1 solution

every time clear groupComboBox before adding datasource
Miguelribeiro 25-Oct-12 4:53am
Doesn't Work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900