Microsoft Exam Questions

Which code segment should you use?

You create a Web Form. The Web Form uses the FormView control to enable a user to edit a record in the database. When the user clicks the Update button on the FormView control, the application must validate that the user has entered data in all of the fields. You need to ensure that the Web Form does not update if the user has not entered data in all of the fields. Which code segment should you use?

A.
protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) { foreach (DictionaryEntry entry in e.Keys)
{ if (entry.Value.ToString() == System.String.Empty) {e.Cancel=true;return;
}
}
}

B.
protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e) { foreach (DictionaryEntry entry in e.NewValues)
{ if (entry.Value.Equals(""))
{e.KeepInEditMode=true;return;
}
}
}

C.
protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) { foreach (DictionaryEntry entry in e.NewValues)
{ if (entry.Value.Equals(""))
{ e.Cancel=true;return
}
}
}

D.
protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e) { foreach (DictionaryEntry entry in e.Keys)
{ if (entry.Value.ToString() == System.String.Empty) {e.KeepInEditMode=true;return;
}
}
}