Pergunta

1) I have 2 tables IncludedProducts {ID} and Products {ID, Name, Code}

2) In an xtraGrid control I want to show list of products which has their IDs in IncludedProducts table, with possibility to add new products using in-place GridLookUpEdit editors and push data back to database (store changes to IncludedProducts table) after the user presses button "Save"

For example

Products table

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

IncludedProducts table

|ID|
|3 |

In the application I need

1) XtraGrid control to show

|Name  |Code|
|Cheese|C01 | 

2) when i start typing in each of XtraGrid's columns it should show dropdown grid. When I choose item from the dropdown grid, it should fill BOTH(!) columns (in order to achieve this, I have to set ValueMember=ID for both Name and Code columns)

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)

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top