0

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?

1
  • Something is clearly wrong with the EDC. Commented Oct 4, 2012 at 19:20

1 Answer 1

0

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);

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.