4

Based on How to add new field to custom list (See edit!)

It is a different question relating to the above so thought I'd create a new question as the above was technically answered.

But after adding a new field (Staff Type) to the list I can create new list items without a problem, all values get stored correctly. However, if I edit an existing list item and change the Staff Type then a new list item will be created with default values for all fields except Staff Type. It maintains the value that Staff Type was changed to.

If I edit a list item but don't change the Staff Type, all other fields update correctly.

Any help much appreciated.

EDIT: Ok a detailed description (with pictures)

I create a new course (NewForm.aspx)

enter image description here

You can see I have set the new field, Staff Type and the Title has been set.

I display the course (DispForm.aspx)

enter image description here

You can see that all fields are set as I entered them in NewForm.aspx

I go to edit the course (EditForm.aspx)

enter image description here

You can see that I have changed the Title and added a selection to Staff Type.

When I save it it has done 2 things. Created a new course at the date and time of the save with the new Staff Type selections and empty fields for the rest.

enter image description here

It has also saved the original list item's Title, as I would have expected the Staff Type to be saved also. But the Staff Type is still what was entered in NewForm.aspx.

enter image description here

Does this clarify matters any?

4
  • This isn't making a lot of sense to me. Can you clarify it a little, perhaps give file names of the pages you are referring to when these issues are occuring. It's sounding like you have what you think is an edit form but is acting like a new form. Can you go into the list and use the default EDitForm.aspx page? Commented May 18, 2011 at 15:04
  • Yes, it is in EditForm.aspx. As I said I can change all fields on the form and they update correctly, except for Staff Type. Say I update the Title and the Staff Type. A new list item will be created with the current date and time and only the Staff Type will be populated. But also, it will have edited the Title in the original list item correctly. Commented May 18, 2011 at 15:09
  • I have edited above with pictures to try to describe the problem more clearly. Commented May 18, 2011 at 15:36
  • +1 for screenshots :) Commented May 18, 2011 at 15:51

2 Answers 2

1

Ok I found the answer! Complete "D'oh" moment. On the SharePoint:FormField it had the property

__designer:bind="{ddwrt:DataBind('i'......etc

I replaced the i with a u

__designer:bind="{ddwrt:DataBind('u'......etc

And it works. Can anyone explain what the difference is?

EDIT: A quick check sees i is insert and u is update. I have spent too long looking into this simple mistake. What's the point in ControlMode if you need this set as well?

1
  • ControlMode is if you construct the FormContext yourself completely. Ie. using FormFields in an Application Page. Commented May 19, 2011 at 13:31
0

Try changing the ControlMode on SharePoint:FormField to Edit.

1

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.