I am building a custom form and I am using ItemPicker control to fetch data from an external entity . I am able to fetch the data using the ItemPicker but my next work is to fetch the value from this control and apply some transition to it before saving the data.

Is there any way / any property of the ItemPicker that would let me access the selected value?

I have also tried using the ItemPicker's Entity property but it always returns be 0 count.

How can I achieve this?

Thanks, --OM

  • I get NullReferenceException: Object reference not set to an instance of an object. when debuger hits the bdcClientSelector.ValidateEntity(peClient) ItemPicker control is set up correctly since i can pick any value from Item Picker Dialog and it fills the control with selected item ... I tried putting inside of Run with elevated privileges ... it's the same. Any advice on this one ? Commented Apr 30, 2013 at 8:26

1 Answer 1


Okay so here it is.

After few hours of banging my head I was able to get this. All you need to do is create a PickerEntity instance and add it to the entities collection of pickerItem to set the values.

    peClient = new PickerEntity();
    peClient.DisplayText = item["Client"].ToString();
    peClient.Key = item["dbo_x002e_Customer_ID"].ToString();

To read the value you again need to type cast ItemPicker.Entities[0] to picker entity instance and use the Key , DisplayText or ExtendedData property to get the relevant values.

PickerEntity bdcEntity = (PickerEntity)YourEntityPickerId.Entities[0];

Just a few finding: 1. It would good to set the .IsResolved property while setting so that it can be fetched later using the .ResolvedEntities property of the ItemPicker 2. It is always a good idead to use .ResolvedEntities to fetch the data from ItemPicker as .Entities 's behaviour is unpredictable.

For more details, please read through:




Code blocks quoted above are taken from these posts . Hope this helps.



Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.