public override DataControlFieldsEditor.FieldItem[] CreateFields(DataBoundControl control, IDataSourceFieldSchema[] fieldSchemas) { if (fieldSchemas == null) { return null; } ArrayList list = new ArrayList(); foreach (IDataSourceFieldSchema schema in fieldSchemas) { if (((control is GridView) && ((GridView) control).IsBindableType(schema.DataType)) || ((control is DetailsView) && ((DetailsView) control).IsBindableType(schema.DataType))) { BoundField runtimeField = null; DataControlFieldsEditor.FieldItem item = null; string name = schema.Name; if ((schema.DataType == typeof(bool)) || (schema.DataType == typeof(bool?))) { runtimeField = new CheckBoxField { HeaderText = name, DataField = name, SortExpression = name }; item = new DataControlFieldsEditor.CheckBoxFieldItem(this._fieldsEditor, (CheckBoxField) runtimeField); } else { runtimeField = new BoundField { HeaderText = name, DataField = name, SortExpression = name }; item = new DataControlFieldsEditor.BoundFieldItem(this._fieldsEditor, runtimeField); } if (schema.PrimaryKey) { runtimeField.ReadOnly = true; } if (schema.Identity) { runtimeField.InsertVisible = false; } item.LoadFieldInfo(); list.Add(item); } } return (DataControlFieldsEditor.FieldItem[]) list.ToArray(typeof(DataControlFieldsEditor.FieldItem)); }
public override DataControlFieldsEditor.FieldItem CreateField() { BoundField runtimeField = new BoundField(); string name = string.Empty; if (this._fieldSchema != null) { name = this._fieldSchema.Name; } if (!this._genericBoundField) { runtimeField.HeaderText = name; runtimeField.DataField = name; runtimeField.SortExpression = name; } if (this._fieldSchema != null) { if (this._fieldSchema.PrimaryKey) { runtimeField.ReadOnly = true; } if (this._fieldSchema.Identity) { runtimeField.InsertVisible = false; } } DataControlFieldsEditor.FieldItem item = new DataControlFieldsEditor.BoundFieldItem(this._fieldsEditor, runtimeField); item.LoadFieldInfo(); return item; }