Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
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 ? –  displayName Apr 30 '13 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();
    bdcClientSelector.Entities.Add(bdcClientSelector.ValidateEntity(peClient));

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:

http://karinebosch.wordpress.com/sharepoint-controls/peopleeditor-control/

http://www.myfatblog.co.uk/?p=118

http://www.fftf.org/news/Jun08feed/Using_a_BDC_ItemEntity_Picker_Control_in_Custom_SharePoint_Application_Pages.rss.html

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

Cheers,

--OM

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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