Question

We are using SharePoint 2010 Foundation.

We have an item in a list that is a dropdown with values from another list.

When we access the list as a SharePoint list it works fine, we can select a value, save the list, the next time we access the list the correct value is selected.

We have programmed a form that will updated the list. When we pull up the form, select a value and save it, we can see by accessing the list directly that the value has been saved.

However, when we pull up the form again it is the first item in the list that is selected. Have tried storing the selected value is a temp variable before binding the list but have not been able to get it to work. Anyone know how to fix this?

Was it helpful?

Solution

We found a solution.

The trick was to get the number that is the first part of the ToString of the SPListItem, before binding the list.

Then use that number to set the selected value after the list is bound

Parameters:

 SPListItem currentItem, string fieldName

Code:

 string selectedValue = currentItem[fieldName].ToString().Substring(0,1);

 //... Bind list

 ddlLookup.SelectedValue = selectedValue;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top