internal static IDictionary<Type, DataControlFieldDesigner> GetCustomFieldDesigners(DesignerForm designerForm, DataBoundControl control) { Dictionary<Type, DataControlFieldDesigner> dictionary = new Dictionary<Type, DataControlFieldDesigner>(); ITypeDiscoveryService service = (ITypeDiscoveryService) control.Site.GetService(typeof(ITypeDiscoveryService)); if (service != null) { foreach (Type type in service.GetTypes(typeof(DataControlField), false)) { DesignerAttribute customAttribute = (DesignerAttribute) Attribute.GetCustomAttribute(type, typeof(DesignerAttribute)); if (customAttribute != null) { Type type2 = Type.GetType(customAttribute.DesignerTypeName, false, true); if ((type2 != null) && type2.IsSubclassOf(typeof(DataControlFieldDesigner))) { try { DataControlFieldDesigner designer = (DataControlFieldDesigner) Activator.CreateInstance(type2); if (designer.IsEnabled(control)) { designer.DesignerForm = designerForm; dictionary.Add(type, designer); } } catch { } } } } } return dictionary; }
/// <summary> /// 分页数据绑定(列表控件和数据控件) /// </summary> /// <param name="ctrl">绑定控件</param> /// <param name="source">数据源</param> /// <param name="pager">分页控件</param> public static void BindControl(DataBoundControl ctrl, DataSet source, AspNetPager pager) { if (source.Tables.Count < 1) return; ctrl.DataSource = source.Tables[0]; ctrl.DataBind(); pager.RecordCount = Convert.ToInt32(source.Tables[1].Rows[0][0]); pager.SetRewriteUrl(); }
internal static ITemplate GetTemplate(DataBoundControl control, string templateContent) { try { IDesignerHost service = (IDesignerHost) control.Site.GetService(typeof(IDesignerHost)); if ((templateContent != null) && (templateContent.Length > 0)) { return ControlParser.ParseTemplate(service, templateContent, null); } return null; } catch (Exception) { return null; } }
internal static TemplateField GetTemplateField(DataControlField dataControlField, DataBoundControl dataBoundControl) { TemplateField field = new TemplateField { HeaderText = dataControlField.HeaderText, HeaderImageUrl = dataControlField.HeaderImageUrl, AccessibleHeaderText = dataControlField.AccessibleHeaderText, FooterText = dataControlField.FooterText, SortExpression = dataControlField.SortExpression, Visible = dataControlField.Visible, InsertVisible = dataControlField.InsertVisible, ShowHeader = dataControlField.ShowHeader }; field.ControlStyle.CopyFrom(dataControlField.ControlStyle); field.FooterStyle.CopyFrom(dataControlField.FooterStyle); field.HeaderStyle.CopyFrom(dataControlField.HeaderStyle); field.ItemStyle.CopyFrom(dataControlField.ItemStyle); return field; }
public override TemplateField GetTemplateField(DataBoundControl dataBoundControl) { TemplateField templateField = base.GetTemplateField(dataBoundControl); HyperLinkField runtimeField = (HyperLinkField) base.RuntimeField; System.Type controlType = typeof(HyperLink); StringBuilder builder = new StringBuilder(); builder.Append("<asp:"); builder.Append(controlType.Name); builder.Append(" runat=\"server\""); if (runtimeField.DataTextField.Length != 0) { builder.Append(" Text='<%# "); builder.Append(DesignTimeDataBinding.CreateEvalExpression(runtimeField.DataTextField, base.PrepareFormatString(runtimeField.DataTextFormatString))); builder.Append(" %>'"); } else { builder.Append(" Text=\""); builder.Append(runtimeField.Text); builder.Append("\""); } if ((runtimeField.DataNavigateUrlFields.Length != 0) && (runtimeField.DataNavigateUrlFields[0].Length > 0)) { builder.Append(" NavigateUrl='<%# "); builder.Append(DesignTimeDataBinding.CreateEvalExpression(runtimeField.DataNavigateUrlFields[0], base.PrepareFormatString(runtimeField.DataNavigateUrlFormatString))); builder.Append(" %>'"); } else { builder.Append(" NavigateUrl=\""); builder.Append(runtimeField.NavigateUrl); builder.Append("\""); } if (runtimeField.Target.Length != 0) { builder.Append(" Target=\""); builder.Append(runtimeField.Target); builder.Append("\""); } builder.Append(" id=\""); builder.Append(base.fieldsEditor.GetNewDataSourceName(controlType, 0)); builder.Append("\"></asp:"); builder.Append(controlType.Name); builder.Append(">"); templateField.ItemTemplate = base.GetTemplate(dataBoundControl, builder.ToString()); return templateField; }
public virtual TemplateField GetTemplateField(DataBoundControl dataBoundControl) { return DataControlFieldHelper.GetTemplateField(this.runtimeField, dataBoundControl); }
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)); }
protected ITemplate GetTemplate(DataBoundControl control, string templateContent) { return DataControlFieldHelper.GetTemplate(control, templateContent); }
public abstract TemplateField CreateTemplateField(DataControlField dataControlField, DataBoundControl dataBoundControl);
internal MyDataBoundControlAdapter (DataBoundControl c) : base (c) { }
public override TemplateField GetTemplateField(DataBoundControl dataBoundControl) { TemplateField templateField = base.GetTemplateField(dataBoundControl); templateField.SortExpression = base.RuntimeField.SortExpression; templateField.ItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(0, false)); templateField.ConvertEmptyStringToNull = ((BoundField) base.RuntimeField).ConvertEmptyStringToNull; templateField.EditItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(1, ((BoundField) base.RuntimeField).ReadOnly)); if ((dataBoundControl is DetailsView) && ((BoundField) base.RuntimeField).InsertVisible) { templateField.InsertItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(2, false)); } return templateField; }
public virtual DataControlFieldsEditor.FieldItem[] CreateFields(DataBoundControl control, IDataSourceFieldSchema[] fieldSchemas) { return null; }
public DataBoundControlAdapter (DataBoundControl c) : base (c) {}
private WebGridView DetailControl(DataBoundControl MasterControl) { WebGridView gdView = null; object obj = this.GetObjByID(MasterControl.DataSourceID); if (obj != null && obj is WebDataSource) { WebDataSource wds = (WebDataSource)obj; WebDataSource wdsDetail = null; wdsDetail = (WebDataSource)this.ExtendedFindChildControl(wds.ID, FindControlType.MasterDataSource, typeof(WebDataSource)); if (wdsDetail != null) { gdView = (WebGridView)this.ExtendedFindChildControl(wdsDetail.ID, FindControlType.DataSourceID, typeof(WebGridView)); } } return gdView; }
public override TemplateField GetTemplateField(DataBoundControl dataBoundControl) { TemplateField templateField = base.GetTemplateField(dataBoundControl); ImageField runtimeField = (ImageField) base.RuntimeField; templateField.SortExpression = runtimeField.SortExpression; templateField.ItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(0)); templateField.ConvertEmptyStringToNull = runtimeField.ConvertEmptyStringToNull; if (!runtimeField.ReadOnly) { templateField.EditItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(1)); if (dataBoundControl is DetailsView) { templateField.InsertItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(2)); } } return templateField; }
public override TemplateField GetTemplateField(DataBoundControl dataBoundControl) { TemplateField templateField = base.GetTemplateField(dataBoundControl); ButtonField runtimeField = (ButtonField) base.RuntimeField; StringBuilder builder = new StringBuilder(); System.Type controlType = typeof(System.Web.UI.WebControls.Button); if (runtimeField.ButtonType == ButtonType.Link) { controlType = typeof(LinkButton); } else if (runtimeField.ButtonType == ButtonType.Image) { controlType = typeof(ImageButton); } builder.Append("<asp:"); builder.Append(controlType.Name); builder.Append(" runat=\"server\""); if (runtimeField.DataTextField.Length != 0) { builder.Append(" Text='<%# "); builder.Append(DesignTimeDataBinding.CreateEvalExpression(runtimeField.DataTextField, base.PrepareFormatString(runtimeField.DataTextFormatString))); builder.Append(" %>'"); } else { builder.Append(" Text=\""); builder.Append(runtimeField.Text); builder.Append("\""); } builder.Append(" CommandName=\""); builder.Append(runtimeField.CommandName); builder.Append("\""); if ((runtimeField.ButtonType == ButtonType.Image) && (runtimeField.ImageUrl.Length > 0)) { builder.Append(" ImageUrl=\""); builder.Append(runtimeField.ImageUrl); builder.Append("\""); } builder.Append(" CausesValidation=\"false\" id=\""); builder.Append(base.fieldsEditor.GetNewDataSourceName(controlType, 0)); builder.Append("\"></asp:"); builder.Append(controlType.Name); builder.Append(">"); templateField.ItemTemplate = base.GetTemplate(dataBoundControl, builder.ToString()); return templateField; }
private string GetTableName(DataBoundControl control) { var dataSourceCtl = FindControl(Page.Controls, control.DataSourceID) as IDynamicDataSource; if (dataSourceCtl == null) throw new InvalidOperationException("DataSource control not found or it doesn't implement IDynamicDataSource"); var table = dataSourceCtl.GetTable(); if (table == null) throw new InvalidOperationException("MetaTable not found"); return table.Name; }
public override TemplateField GetTemplateField(DataBoundControl dataBoundControl) { TemplateField templateField = base.GetTemplateField(dataBoundControl); CheckBoxField runtimeField = (CheckBoxField) base.RuntimeField; templateField.SortExpression = runtimeField.SortExpression; templateField.ItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(0)); if (!runtimeField.ReadOnly) { templateField.EditItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(1)); } if ((dataBoundControl is DetailsView) && ((CheckBoxField) base.RuntimeField).InsertVisible) { templateField.InsertItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(2)); } return templateField; }
public static void BindDataBoundControl(DataBoundControl ctrl, object dataSource) { ctrl.DataSource = dataSource; ctrl.DataBind(); }
public override TemplateField GetTemplateField(DataBoundControl dataBoundControl) { TemplateField templateField = base.GetTemplateField(dataBoundControl); templateField.ItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(0)); templateField.EditItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(1)); if (dataBoundControl is DetailsView) { templateField.InsertItemTemplate = base.GetTemplate(dataBoundControl, this.GetTemplateContent(2)); } return templateField; }
public abstract bool IsEnabled(DataBoundControl parent);
public override TemplateField GetTemplateField(DataBoundControl dataBoundControl) { if (this._fieldDesigner != null) { return this._fieldDesigner.CreateTemplateField(base.RuntimeField, dataBoundControl); } return base.GetTemplateField(dataBoundControl); }
protected TemplateField GetTemplateField(DataControlField dataControlField, DataBoundControl dataBoundControl) { return DataControlFieldHelper.GetTemplateField(dataControlField, dataBoundControl); }
/// <summary> /// 分页数据绑定(列表控件和数据控件) /// </summary> /// <param name="ctrl"></param> /// <param name="source"></param> /// <param name="RecordCount"></param> /// <param name="pager"></param> public static void BindControl(DataBoundControl ctrl, object source, int RecordCount, AspNetPager pager) { ctrl.DataSource = source; ctrl.DataBind(); pager.RecordCount = RecordCount; pager.SetRewriteUrl(); }