This project is read-only.

Visit my blog:

The SharePoint control provided in this project 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…

The project is… It’s alpha!!!


See the "new2.aspx" and "edit2.aspx" files of the "List2" in the "Test"-Project. There you find the usage of the control. You specify the "first" and "second" lookup field and you specify a SharePoint list that contains the dependencies between the values.

To use the project you need a local SharePoint with host header "sharepoint.local". There you need a site collection "/sites/spconditionallookup", e.g. a Team Site.

If you have set up the project you can navigate to "http://sharepoint.local/sites/spconditionallookup/Lists/List2/AllItems.aspx" and add a new item. There you see the control working.


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> 

Last edited Dec 30, 2010 at 9:41 PM by ikarstein, version 9