Friday, August 30, 2013

Populating the data to drop down list from another list without creating lookup column

Populating the data to drop down list from another list without creating lookup column

WHY??

few scenarios, when you have a look up column, if you delete the item from the look up, users cannot see the that item’s value where they have used in while creating

this leads to retain the column values, also if you delete or add any items in Country (source list) the reflect in the target list where we are looking up

OUR testers tested this scenario to solve this issue I proceeded with below approach

1) Create a list

2) add a choice or single line text column to the list, in my case country

3) Open the list in SharePoint designer

4) create a new form for your list

5) you will get a web part having all the columns in the page

6) your created  choice column will look like below

 

<SharePoint:FormField runat="server" id="ff25{$Pos}" ControlMode="New" FieldName="Country" __designer:bind="{ddwrt:DataBind('i',concat('ff25',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Country')}"/>


7) create a another row through designer.

8) Insert data source from the ribbon. select your source list


insertdatasource

<td class="ms-formlabel">
<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" UseServerDataFormat="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="spdatasource1">
<SelectParameters><asp:parameter Name="ListID" DefaultValue="7587B054-1CB0-4AF3-B419-1023C67EA93F" /></SelectParameters>
<DeleteParameters><asp:parameter Name="ListID" DefaultValue="7587B054-1CB0-4AF3-B419-1023C67EA93F" /></DeleteParameters>
<UpdateParameters><asp:parameter Name="ListID" DefaultValue="7587B054-1CB0-4AF3-B419-1023C67EA93F" /></UpdateParameters>
<InsertParameters><asp:parameter Name="ListID" DefaultValue="7587B054-1CB0-4AF3-B419-1023C67EA93F" /></InsertParameters>
</SharePoint:SPDataSource>
</td>


<SharePoint:DVDropDownList Width="175px" runat="server" id="ff25{$Pos}" __designer:bind="{ddwrt:DataBind('i',concat('ff25',$Pos),'SelectedValue','SelectedIndexChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ResourceName')}" Width="76px" selectedvalue="{@ResourceName}" datasourceid="spdatasource1" datatextfield="Title" datavaluefield="Title" />



9) change your FORMFIELD to above control,


10) Done


No comments:

Post a Comment