使用带有Linq的ComboBox到Sql和关系 [英] using ComboBox with Linq to Sql and relationships
本文介绍了使用带有Linq的ComboBox到Sql和关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用另一个表中的值更新一个表中的字段,
如果外键已链接到同一表中的主键,但我似乎已成功实现数据绑定,但似乎无法使其在关系表上正常工作,
Hi,
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);
每当我提交更改时,无论我选择的值为何,它都会插入0
谢谢.
Everytime i submit changes, it inserts 0 regardless of the value i select
Thanks.
推荐答案
每次添加数据源之前都要清除groupComboBox
every time clear groupComboBox before adding datasource
这篇关于使用带有Linq的ComboBox到Sql和关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文