protected void DetailsView1_ItemUpdating(object sender, System.Web.UI.WebControls.DetailsViewUpdateEventArgs e)
{
//Making a DetailsView field read only will prevent the user from changing it.
//This code will make sure that any such fields get passed during the database update.
foreach (DataControlField DetailsViewDataControlField in sender.Fields) {
if (DetailsViewDataControlField is BoundField) {
BoundField DetailsViewBoundField = DetailsViewDataControlField;
string FieldName = DetailsViewBoundField.DataField;
if (DetailsViewBoundField.ReadOnly == true) {
e.NewValues.Item(FieldName) = e.OldValues.Item(FieldName);
}
}
}
}
Make sure read-only DetailsView fields get passed to database
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment