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 have a control that refrences an EDC (added to the list as a lookup) that I have added to an application page via the following markup:

<SharePoint:FormField runat="server" 
   id="Industry" 
   ControlMode="New" 
   FieldName="Industry" 
   />

The problem is that it is outputting the this HTML (notice the value attributes):

<select name="bigLongName" id="bigLongId" title="Industry">
   <option value="0">Compact Machine Solutions</option>
   <option value="0">Earthmoving Excavating</option>
   <option value="0">Earthmoving Grading</option>
   <option value="0">Paving</option>
   <option selected="selected" value="0">Terrain</option>
</select>

What have I done wrong here?

share|improve this question
    
Something is clearly wrong with the EDC. –  Robert Kaucher Oct 4 '12 at 19:20

1 Answer 1

up vote 0 down vote accepted

We had crated the column as a standard lookup in the code that created the list. This caused the <select> to be displayed rather than an externam picker. I was not able to find an adequate explanation of how to create an External Data Column (BDC) in code but managed to work it out.

Here is what I did:

  1. In SharePoint Designer I browsed to the site, External Content Types and then selected the External Content Types I wished to add as an External DataColumn.
  2. I clicked Export BDC Model and saved it to an easy to find location.
  3. I opened it in NotePad++ and used the values in the XML to find the required fields to create the column.

SPBusinessDataField industryBcsField = currentList.Fields.CreateNewField("BusinessData", "Industry") as SPBusinessDataField;

industryBcsField.SystemInstanceName = "BusinessProcess"; //Corresponds to <LobSystemInstance Name="BusinessProcess"> in the BDC Model
industryBcsField.EntityNamespace = "NameSpace"; //Corresponds to <Entity Namespace="Whatever is in these quotes" in your BDC Model.
industryBcsField.EntityName = "Industry";
industryBcsField.HasActions = true;
industryBcsField.BdcFieldName = "Industry"; //The field you wish to display in the list

currentList.Fields.Add(industryBcsField);
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.