views:

21

answers:

1

Hi,

I am updating some list items through code.

Here is an example of what I am trying to do

SPListItem item = GetListItem();

item["Field1"] = GetField1ValueFromControl();
item["Field2"] = GetField2ValueFromControl();
item.Update();

if (!item.MissingRequiredFields)
{
  SuccessRedirect();
}
else
{
  Error("Fields missing");
}

In this example the Field2 is set as a required field, so if the user doesn't enter a value then it would show an error and they could enter a value.

The problem I seem to be having is that after the first error, even after they have entered a value for the required field the MissingRequiredFields property is still returning true after they have resubmitted the page

Any one got any ideas?

A: 

I worked this out.

You need to use the Page.IsValidated method to check the controls.

The item will always update whether the required fields are entered or not.

The MissingRequiredFields is not valid until after the update.

statto