0

1) 我有 2 个表 IncludedProducts {ID} 和 Products {ID, Name, Code}

2)在 xtraGrid 控件中,我想显示在 IncludedProducts 表中具有其 ID 的产品列表,可以在用户按下后使用就地 GridLookUpEdit 编辑器添加新产品并将数据推送回数据库(将更改存储到 IncludedProducts 表)按钮“保存”

例如

产品表

|ID|Name  |Code|
|1 |Lemon |L01 |
|2 |Apple |A01 |
|3 |Cheese|C01 |
|4 |Bread |B01 |

包含产品表

|ID|
|3 |

在我需要的应用程序中

1) XtraGrid 控件显示

|Name  |Code|
|Cheese|C01 | 

2) 当我开始在 XtraGrid 的每个列中输入时,它应该显示下拉网格。当我从下拉网格中选择项目时,它应该填充 BOTH(!) 列(为了实现这一点,我必须为 Name 和 Code 列设置 ValueMember=ID)

3) when I press "Save" button it should update data to IncludedProducts table (contains only ID column)

The part I do not understand

In order to show Code and Name values in XtraGrid control, I have to set DataSource that contains ID, Name and Code (for in-place editor's repositoryItem's DisplayMember) columns (that would be a join of Products and IncludedProducts table), right? But when I want to save data to database I want it to be written to IncludedProducts table - that is storing only ID column.

How can I do this?

P.S. I want to achieve this using Entity Framework model, not DataSets, can you please provide me with some quidance?

This is what I've got working this far (only loading data from db, setting in-place editors, but no luck sending data back to database) problems setting XtraGrid with in-place editor-s (using GridLookUpEdit)

4

1 回答 1

0

The problem was, that i acctually had additional column in IncludedProducts table, when I added it to the xtraGrid, and provided it with a valid value, the update to IncludedProducts table was successful

于 2013-04-08T13:14:35.377 回答