DevExpress RepositoryItemLookUpEdit

Jonny picture Jonny · Aug 29, 2011 · Viewed 8.2k times · Source

I am binding the Grid with a business object which contains a field Country (which is another business object containing ID and Name). I want to display the country name set to the "Country" in the business object for each row. However if the user wishes to change the country then I want to show the user a drop down list with all the countries available.

I'm stuck with getting the SlectedValue from the repositoryItemLookUpEdit and setting the Selected value

Answer

AussieALF picture AussieALF · Sep 14, 2011

All you should have to do is assign a RepositoryItemLookupEdit to the Column.Edit property.

Then in your RepositoryItemLookupEdit set the Datasource to a IList of all your Country objects.

Set the RepositoryItemLookupEdit.DisplayMember to "Name" and leave ValueMember as blank (this will make the object itself the value)

Then your grid should handle everything for you, as if you click on the dropdown and select a new country the selected Country object will be assigned to that cell's value.

Keep in mind however that the Objects much be the same Reference match... ie. If your Business Objects Country object isn't apart of the IList of Countries then it won't display a value.

Are you using XPO at all?