CodePlex project uploaded: SharePoint 2010 Conditional Lookup Control

I’ve created a custom control for SharePoint 2010. This control let you connect two lookup fields so that the second lookup field contains only a subset of all values depending on the selected value of the first lookup field.

The control can handle both rendering methods of SharePoint for lookup fields: If there are more then 20 items in a lookup dropdown it will be rendered alternatively as input text box and not as input dropdown…

But… It’s alpha!!!


Some Screenshots…

This is the demo list where you start using the demo.


Add a new item. You see two input controls. Both are empty.


Now you open the dropdown list of the first field:


There are values in Winking smile – Leave it on “(none)” for now.

Open the dropdown of the second field:


Its empty Smile

Now select the value “List1-Value1” in the first dropdown.


Now open the second dropdown. Now there are values in there Smile :


The second dropdown was filled with values depending on the selected value of the first dropdown.

Lets have a look behind the scene.

Open the List “This list defines the value dependencies between the main list and the conditional list”:


This list defines the values for the second dropdown depending on the values of the first dropdown.

For value “List1-Value1” you’ll find there 4 values:


Lets have a look into the project:


The Test project has 4 SharePoint List definitions… “List 1” is the “main list” and “List 3” is the “conditional list”. “List 2” will contain the items you create. “RefList” contains the dependencies between “List 1” and “List 3”.

“List 2” contains to custom list forms:


“New2” is used to create new items, “Edit2” is used to edit items.

Lets have a look into “New2”. There are only a few customizations for using the Conditional Lookup control.


This references to the input fields “ff1” and “ff2”:

1:                             <tr> 
2:                                 <td> 
3:                                     <table  border="0"  cellspacing="0"  width="100%"> 
4:                                         <tr> 
5:                                             <td  width="190px"  valign="top"  class="ms-formlabel"> 
6:                                                 <h3  class="ms-standardheader"> 
7:                                                     <nobr> Reference (lookup) to the main list </nobr> 
8:                                                 </h3> 
9:                                             </td> 
10:                                             <td  width="400px"  valign="top"  class="ms-formbody"> 
11:                                                 <SharePoint:FormField  runat="server"  ID="ff1"  ControlMode="New"  FieldName="List2RefToList1FieldA"  /> 
12:                                                 <SharePoint:FieldDescription  runat="server"  ID="ff1description"  FieldName="List2RefToList1FieldA" 
13:                                                     ControlMode="New"  /> 
14:                                             </td> 
15:                                         </tr> 
16:                                         <tr> 
17:                                             <td  width="190px"  valign="top"  class="ms-formlabel"> 
18:                                                 <h3  class="ms-standardheader"> 
19:                                                     <nobr> Reference (lookup) to the conditional list</nobr> 
20:                                                 </h3> 
21:                                             </td> 
22:                                             <td  width="400px"  valign="top"  class="ms-formbody"> 
23:                                                 <SharePoint:FormField  runat="server"  ID="ff2"  ControlMode="New"  FieldName="List2RefToList3FieldA"/> 
24:                                                 <SharePoint:FieldDescription  runat="server"  ID="ff2description"  FieldName="List2RefToList3FieldA" 
25:                                                     ControlMode="New"  /> 
26:                                             </td> 
27:                                         </tr> 
28:                                         <tr  id="idAttachmentsRow"> 
29:                                             <td  nowrap="true"  valign="top"  class="ms-formlabel"  width="20%"> 
30:                                                 <SharePoint:FieldLabel  ControlMode="New"  FieldName="Attachments"  runat="server"  /> 
31:                                             </td> 
32:                                             <td  valign="top"  class="ms-formbody"  width="80%"> 
33:                                                 <SharePoint:FormField   runat="server"  ID="AttachmentsField"  ControlMode="New"  FieldName="Attachments"/> 
34:                                             </td> 
35:                                         </tr> 
36:                                     </table> 
37:                                 </td> 
38:                             </tr> 

3 thoughts on “CodePlex project uploaded: SharePoint 2010 Conditional Lookup Control

    • Thanks Kirill! – I’ll do my very best 🙂 – BUT: At the moment there are some more projects I want to publish. After that I’ll improve my “old” projects. – You are welcome to help developing them!!!

      Kind regards

  1. I am facing a design issue in these controls the second drop list was poping under the first drop down. i am not getting where is the fault. as per css it has proper styles. can u guide me on this.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.