Click here to Skip to main content
15,743,541 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I would like to setup a datagridview that is populated using Linq To SQL. Within that, one of the columns should be a combobox that also uses LinqToSQL for a foreign key reference in another table.

I would like for this to be updateable - that is update the database when the user adds or changes records.

Could anyone point me to an example or provide hints as to how to do this?

1) the DataGridView Source is a table (Persons) that has a FK link to another table (Roles). The key is internal, but want to display the RoleName (string)

2) want to fill the dropdown list with the list of RoleNames. When one is selected, the underlying table is updated with the Role ID.

4) columns are not autogenerated, I was manually generating them to control the order and whether displayed at all

5) language is c#

6) this is Datagrivdview, in Forms (not

Updated 1-Apr-10 8:07am

What examples do you need? LinqToSql just produces an IEnumerable result that can be used as a datasource for your grid and combobox, nothing really special about it.
Share this answer
please let me know that combobox is dynamically bind or it is static bind. if you want to bind dynamically then you have to bind combobox using RowBound method of gridview. in case of static binding of combobox(dropdownlist) you have to bind using itemTemplate in TemplateField <itemTemplate> in gridview. please specifies which language are you using then i will tell you right solution
Share this answer
I updated the original question
Share this answer

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