0

I'm using a gridcontrol on which I have 3 columns.

On one of the columns I use a repository item lookup edit. My problem appears when I update the grid's datasource with tableadapter update method, after that all the other columns remain with the right selection of data,but the on the column with the repository the cells are empty..but the data is present, so no text displayed, but data present.

Any ideas on how to make this work?

2 Answers 2

0

The thing with the RepositoryItemLookupEdit is that the DisplayValue member shows nothing if the old selected value does not exist in the new set of data. So you have to check if the new loaded data contains in effect the old value EditValue ..

Sign up to request clarification or add additional context in comments.

1 Comment

I've solved it.The problem was that in the source database the value field was nvarchar(9) and in the destination datasource in which I was inserting data was nvarchar(20).I belive that when data was brought trough tableadapter there was no triming in the value member so the the were an additional 11 characters of nothing so the look up edit could not make a match between them.
0

You need to make sure that you've set the Editor's DataSource correctly, and, as previously mentioned, the DisplayMember and ValueMember properties. Display Member will determine what is shown in the editor itself, and the Value Member is what will be used to bind against. So, you could have an (int) ID for the Value Member and a (string) Name or Description for the Display Member. The most important thing here is setting and updating the DataSource property of the editor properly. You can accomplish this in the Designer, or in the code itself by directly accessing the editor's DataSource property and setting it to a collection of your domain objects when the form loads or initializes.

Additionally, you can create a BindingSource from your domain object that you can use to map to the data source, or (I would recommend) creating a view model that decorates your domain object. This allows you to massage the data as necessary. In some cases, you may want some validation or formatting to take place before or after the data is shown or bound.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.