Using External Content type or list controls in custom webpart

Okay some time has passed after last post but now I have something pretty interesting in my mind. Lately I have been digging SharePoint 2010’s External List and External Content types (Business Connectivity Services, BCS). I need to make my own webpart (Visual Web Part or the regular one) that makes use of the picker that Microsoft uses when you set up your list with either directly External Content type or through lookup field to External List.

From the background I knew instantly that this will be tricky one (due to fact that External List Items are not like SPListItem’s and enumerating external list from code requires bits and pieces of extra with user security and so on).

If you look standard SharePoint 2010 edit form page with developer tools (in IE9) you’ll see that in UI there is mention about the SPFieldBusinessData. Now if you try to search with that term you’ll find pretty much nothing and Visual Studio does not help you either. At first I was hoping that yes it is like regular field in SharePoint but no luck.

After digging more I found some intresting posts about setting up ItemPicker with ExtendedData. Through UI this looks exactly same as the normal SharePoint’s External Item Picker but requires quite good amount of work setting up the ExtendedData. Also I found this not so appealing since in List we have done work already by defining External Content Type and some more properties.

So the search continued to next solution. After digging more into this I found quite nice solution at the moment for this problem. From some forum posts I found references to BusinessDataFieldControl (Microsoft.SharePoint.WebControls -namespace). If you just put this control to your page you’ll end up getting error about the null controls. This was not a good sign. However now there are big thanks to IntelliSense: from that control you can find properties like ItemId, ListId and FieldName. After setting those three properties you’ll get the control showing up and it works when picker dialog is opened (that nice “instant search” by giving some values to control is not working just yet). This was exactly the easy solution what I was looking for but however there are some limitations currently present.

Although I am still considering about using ItemPicker or keep still on searching for the perfect solution. With BusinessDataFieldControl you can find the data from external source but you can get only one line back at the time (let’s say that you have given the external column to show Company from external source and when you pick the company from dialog you just get the company and nothing more).

The search continues…

Advertisements

About Sakarih

I am SharePoint developer/architect from Finland and my blogposts are all about SharePoint 2007/2010/2013 stuff. There might be also something else posted.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

One Response to Using External Content type or list controls in custom webpart

  1. Extreme says:

    Hi, I am trying to use the ItemPicker control on my application page but with no luck. Have you solved this? Any hint is welcome.
    Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s