Click here to Skip to main content
15,883,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have, multiple tables,
HTML
division,
department,
group,
user

each of these have name and id

in another table(usergroupings) i have
HTML
userID
groupID
divisionID
departmentID

which are all foreign keys to the primary tables

this links a user id to a division department and group

now using Linq, i want to be able to populate,
a combo box with the group name etc,
and insert the id into(usergroupings)

I can see the relationed tables in (usergroupings),
but it does not populate the combo box with the values.
C#
dbs = new dbConnDataContext();

var userGrouping =
  from c in dbs.UserGroupings
  select c;
Posted
Updated 7-Oct-12 22:21pm
v2
Comments
Erik Rude 8-Oct-12 4:26am    
Are you using Windows Forms or WPF and what code are you using to bind?
Miguelribeiro 8-Oct-12 4:40am    
HI Erik,
Windows forms,

navUserGroupings.DataSource = userGrouping;
groupComboBox.DisplayMember = "Group.GroupName";
groupComboBox.ValueMember = "Group.ID";

and im using component one input panel control

1 solution

modify your query as below.

C#
var userGrouping =
  from c in dbs.UserGroupings
  select c;
//Bind combobox after the making the list as below.
userGrouping.List();


for more please refer the below link


LINQ to SQL[^]

Hope this will help you.
 
Share this answer
 
v2
Comments
Miguelribeiro 8-Oct-12 5:21am    
Hi,
ive tried that and still no luck,
Mohd. Mukhtar 8-Oct-12 5:26am    
use the below query

var userGrouping =
from c in dbs.UserGroupings
select new{c.*give the column name here.};
//Bind combobox after the making the list as below.
userGrouping.List();

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