public static void RetrieveValues(Control container, EntityFieldDef[] fields, ExtensibleDC dc) { foreach (EntityFieldDef field in fields) { WebControl control = container.FindControl(_prefix + field.Name) as WebControl; if (control == null) { continue; } string textValue = null; if (control is TextBox) { if (!control.Enabled || !control.Visible || (control as TextBox).ReadOnly) { continue; } textValue = (control as TextBox).Text.Trim(); } else if (control is DropDownList) { if (!control.Enabled || !control.Visible) { continue; } textValue = (control as DropDownList).SelectedValue; } else { continue; } dc.SetValue(field.Name, textValue); } }
static public void WriteEntityToDC(ExtensibleEntity entity, ExtensibleDC dc) { FieldMetadata[] fields = entity.Metadata.Fields; for (int i = 0; i < fields.Length; i++) { object value = entity.GetValue(fields[i].Name); dc.SetValue(fields[i].Name, value == null ? null : value.ToString()); } }