コード例 #1
0
            //private static Dictionary<Type, Action<object, object>> map;

            //static DataBindingHelper()
            //{
            //    map = new Dictionary<Type, Action<object, object>>();
            //    map.Add(
            //        typeof(DataBoundControl),
            //            (control, data) =>
            //            {
            //                ((DataBoundControl)control).DataSource = data;
            //                ((DataBoundControl)control).DataBind();
            //            });
            //    map.Add(typeof(BaseDataList),
            //            (control, data) =>
            //            {
            //                ((BaseDataList)control).DataSource = data;
            //                ((BaseDataList)control).DataBind();
            //            });

            //}
            public static void SetDataSourceAndBind(object control, object dataSource)
            {
                if (control is DataBoundControl)
                {
                    DataBoundControl bindable = (DataBoundControl)control;
                    bindable.DataSource = dataSource;
                    bindable.DataBind();
                }
                else if (control is BaseDataList)
                {
                    BaseDataList bindable = (BaseDataList)control;
                    bindable.DataSource = dataSource;
                    bindable.DataBind();
                }
                else if (control is Repeater)
                {
                    Repeater bindable = (Repeater)control;
                    bindable.DataSource = dataSource;
                    bindable.DataBind();
                }
                else
                {
                    throw new NotSupportedException(control.GetType().Name + " is not a supported data control");
                }

                //foreach (var type in map.Keys)
                //{
                //    if (type.IsAssignableFrom(control.GetType()))
                //    {
                //        map[type](control, dataSource);
                //        return;
                //    }
                //}
                //throw new NotSupportedException(control.GetType().Name + " is not a supported data control");
            }
コード例 #2
0
 /// <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();
 }
コード例 #3
0
 public static void SetDataSourceAndBind(object control, object dataSource)
 {
     if (control is DataBoundControl)
     {
         DataBoundControl bindable = (DataBoundControl)control;
         bindable.DataSource = dataSource;
         bindable.DataBind();
     }
     else if (control is BaseDataList)
     {
         BaseDataList bindable = (BaseDataList)control;
         bindable.DataSource = dataSource;
         bindable.DataBind();
     }
     else if (control is Repeater)
     {
         Repeater bindable = (Repeater)control;
         bindable.DataSource = dataSource;
         bindable.DataBind();
     }
     else
     {
         throw new NotSupportedException(control.GetType().Name + " is not a supported data control");
     }
 }
コード例 #4
0
        public static MetaTable FindMetaTable(this Control current)
        {
            // .NET doesn't perform the check, we will
            if (current == null)
            {
                throw new NullReferenceException();
            }

            while (current != null)
            {
                DataBoundControl dbc = current as DataBoundControl;
                if (dbc != null)
                {
                    IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource;
                    if (dds != null)
                    {
                        return(dds.GetTable());
                    }
                }

                current = current.NamingContainer;
            }

            return(null);
        }
コード例 #5
0
        public void CurrentBindData(DataBoundControl objDataBoundControl, ObjectQuery <DbDataRecord> objObjectQuery)
        {
            int recordCount = 0;

            objDataBoundControl.DataSource = objObjectQuery.GetPage <DbDataRecord>(this.Condition, this.SearchSortExpression(), this.PageSize, this.PageIndex, out recordCount);
            this.RecordCount = recordCount;
            objDataBoundControl.DataBind();
        }
コード例 #6
0
ファイル: UserControlBase.cs プロジェクト: wtf-boy/Framework
        public void CurrentBindData <T>(DataBoundControl objDataBoundControl, ObjectQuery <T> objObjectQuery) where T : EntityObject
        {
            int recordCount = 0;

            objDataBoundControl.DataSource = objObjectQuery.GetPage <T>(this.Condition, this.SortExpression, this.PageSize, this.PageIndex, out recordCount);
            this.RecordCount = recordCount;
            objDataBoundControl.DataBind();
        }
コード例 #7
0
ファイル: FilterButton.cs プロジェクト: 243/ConTAX
 public FilterButton(string text, string value, Parameter param, DataBoundControl dbc)
     : base()
 {
     this.param = param;
     this.value = value;
     this.dbc = dbc;
     this.Text = text;
     this.Click += new EventHandler(setParameter);
 }
コード例 #8
0
        /// <summary>
        /// Raised when the news listview is rendered. Prevents from pagination problems.
        /// </summary>
        /// <param name="sender">Element which raised the event.</param>
        /// <param name="e">Event arguments</param>
        protected void listviewShows_PreRender(object sender, EventArgs e)
        {
            DataBoundControl control = (DataBoundControl)sender;

            if (control.Visible)
            {
                IEnumerable <Show> shows = _client.GetShows();
                control.DataSource = shows;
                control.DataBind();
            }
        }
コード例 #9
0
 /// <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();
 }
コード例 #10
0
ファイル: FilterButton.cs プロジェクト: 243/ConTAX
 public static Panel getAlphabetPartition(Parameter param, DataBoundControl dbc)
 {
     Panel parent = new Panel();
     string[] subsetNames = {"ABCD", "EFGH", "IJKL", "MNOP", "QRST", "UVWXYZ", "123..."};
     string[] subsets = { "[a-d]", "[e-h]", "[i-l]", "[m-p]", "[q-t]", "[u-z]", "[^a-zA-Z]" };
     for (int i = 0; i < subsets.Length; i++ )
     {
         FilterButton fb = new FilterButton(subsetNames[i], subsets[i], param, dbc);
         parent.Controls.Add(fb);
     }
     return parent;
 }
コード例 #11
0
        public DataBoundControl FindFilterControl(string sID, string sDATA_FIELD)
        {
            DataBoundControl ctl = null;

            foreach (DataGridItem itm in Items)
            {
                ctl = itm.FindControl(sDATA_FIELD + "_" + sID) as DataBoundControl;
                if (ctl != null)
                {
                    break;
                }
            }
            return(ctl);
        }
コード例 #12
0
        /// <summary>
        /// 设置数据显示控件实例的属性
        /// </summary>
        /// <param name="grid">数据显示控件MyGrid</param>
        public void SetGridInfo(DataBoundControl grid)
        {
            var tmpGrid = grid as DataGridList;

            if (tmpGrid != null)
            {
                tmpGrid.DalCollection = Dal; //设置客户数据的数据访问函数库

                tmpGrid.PageViewID = MasterPageViewID;
                //设置当前用户可以访问的字段——即权限到列表字段

                tmpGrid.CanUseColumns  = MyUser.UserPermission.GetUserColumnIDs(MasterPageViewID, Dal.DalMetadata);
                tmpGrid.UserOnlineInfo = MyUser;
            }
        }
コード例 #13
0
ファイル: FilterButton.cs プロジェクト: 243/ConTAX
    public static Panel getAlphabetFilter(Parameter param, DataBoundControl dbc)
    {
        Panel parent = new Panel(); //parent of FilterButtons
        string[] letters = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
                     "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
                     "W", "X", "Y", "Z"};

        foreach (string letter in letters)
        {
            FilterButton fb = new FilterButton(letter, letter, param, dbc);
            parent.Controls.Add(fb);
        }

        return parent;
    }
コード例 #14
0
 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);
     }
 }
コード例 #15
0
ファイル: DynamicDataManager.cs プロジェクト: raj581/Marvin
        bool ControlIsValid(Control control)
        {
            if (control is Repeater)
            {
                if (control.NamingContainer == null)
                {
                    throw new HttpException("The Repeater control '" + control.ID + "' does not have a naming container.");
                }
                return(true);
            }

            DataBoundControl dbc = control as DataBoundControl;

            if (dbc == null)
            {
                return(false);
            }

            return(true);
        }
コード例 #16
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            DataBoundControl dataBoundControl = context.Instance as DataBoundControl;

            if (dataBoundControl != null)
            {
                IDesignerHost            service       = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
                DataBoundControlDesigner designer      = (DataBoundControlDesigner)service.GetDesigner(dataBoundControl);
                IComponentChangeService  changeService = (IComponentChangeService)provider.GetService(typeof(IComponentChangeService));
                ControlDesigner.InvokeTransactedChange(dataBoundControl, delegate(object callbackContext) {
                    DataControlFieldsEditor form = new DataControlFieldsEditor(designer);
                    DialogResult result          = UIServiceHelper.ShowDialog(provider, form);
                    if ((result == DialogResult.OK) && (changeService != null))
                    {
                        changeService.OnComponentChanged(dataBoundControl, null, null, null);
                    }
                    return(result == DialogResult.OK);
                }, null, System.Design.SR.GetString("GridView_EditFieldsTransaction"));
                return(value);
            }
            return(null);
        }
コード例 #17
0
ファイル: DynamicDataManager.cs プロジェクト: raj581/Marvin
        public void RegisterControl(Control control, bool setSelectionFromUrl)
        {
            // .NET doesn't check for null here, but since I don't like such code, we
            // will do the check and throw the same exception as .NET
            if (control == null)
            {
                throw new NullReferenceException();
            }

            if (!ControlIsValid(control))
            {
                throw new Exception("Controls of type " + control.GetType() + " are not supported.");
            }

            DataBoundControl dbc = control as DataBoundControl;

            if (dbc != null)
            {
                IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource;
                if (dds == null)
                {
                    return;
                }

                MetaTable table = dds.GetTable();
                if (table == null)
                {
                    return;
                }

                GridView gv = control as GridView;
                if (gv != null)
                {
                    gv.ColumnsGenerator = new AutoFieldGenerator(table);
                    return;
                }
            }
        }
コード例 #18
0
 public static void BindDataBoundControl(DataBoundControl ctrl, object dataSource)
 {
     ctrl.DataSource = dataSource;
     ctrl.DataBind();
 }
コード例 #19
0
        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);
        }
コード例 #20
0
        public void RegisterControl(Control control, bool setSelectionFromUrl)
        {
            // .NET doesn't check for null here, but since I don't like such code, we
            // will do the check and throw the same exception as .NET
            if (control == null)
            {
                throw new NullReferenceException();
            }

            if (!ControlIsValid(control))
            {
                throw new Exception("Controls of type " + control.GetType() + " are not supported.");
            }

            // http://forums.asp.net/p/1257004/2339034.aspx
            // http://forums.asp.net/p/1383908/2936065.aspx
            DataBoundControl dbc = control as DataBoundControl;

            if (dbc != null)
            {
                IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource;
                if (dds == null)
                {
                    return;
                }

                RegisterDataSource(dds);
                MetaTable table = dds.GetTable();
                if (table == null)
                {
                    return;
                }

                if (String.IsNullOrEmpty(dds.Where))
                {
                    dds.AutoGenerateWhereClause = true;
                }
                else
                {
                    dds.AutoGenerateWhereClause = false;
                }

                Type contextType = dds.ContextType;
                if (contextType == null)
                {
                    dds.ContextType = table.DataContextType;
                }

                string entityName = dds.EntitySetName;
                if (String.IsNullOrEmpty(entityName))
                {
                    dds.EntitySetName = table.DataContextPropertyName;
                }

                if (AutoLoadForeignKeys)
                {
                    var ldds = dds as LinqDataSource;
                    if (ldds != null)
                    {
                        ldds.LoadWithForeignKeys(table.EntityType);
                    }
                }

                var gv = control as GridView;
                if (gv != null)
                {
                    gv.ColumnsGenerator = new AutoFieldGenerator(table);
                    return;
                }

                var dv = control as DetailsView;
                if (dv != null)
                {
                    dv.RowsGenerator = new AutoFieldGenerator(table);
                    return;
                }
            }
        }
 internal MyDataBoundControlAdapter(DataBoundControl c) : base(c)
 {
 }
コード例 #22
0
ファイル: Image.cs プロジェクト: Flagwind/Zongsoft.Web
		public Image(DataBoundControl owner = null)
		{
			_owner = owner;
		}
コード例 #23
0
 /// <summary>
 /// Binds the with.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="dataSource">The data source.</param>
 /// <createdOn>1/26/2016 9:58 AM</createdOn>
 public static void BindWith(this DataBoundControl control, ICollection dataSource)
 {
     control.DataSource = dataSource;
     control.DataBind();
 }
コード例 #24
0
 internal static void ClearData(this DataBoundControl control)
 {
     control.DataSource = null;
     control.DataBind();
 }
コード例 #25
0
ファイル: Adapters.cs プロジェクト: samcf111/unityMono5.5.0
 public DataBoundControlAdapter(DataBoundControl c) : base(c)
 {
 }
コード例 #26
0
 public abstract bool IsEnabled(DataBoundControl parent);
コード例 #27
0
        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);
        }
コード例 #28
0
 public abstract TemplateField CreateTemplateField(DataControlField dataControlField, DataBoundControl dataBoundControl);
コード例 #29
0
 protected ITemplate GetTemplate(DataBoundControl control, string templateContent)
 {
     return(DataControlFieldHelper.GetTemplate(control, templateContent));
 }
コード例 #30
0
 protected TemplateField GetTemplateField(DataControlField dataControlField, DataBoundControl dataBoundControl)
 {
     return(DataControlFieldHelper.GetTemplateField(dataControlField, dataBoundControl));
 }
コード例 #31
0
        protected void gv_Beneficios_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Int32 index = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName.Equals("Select"))
            {
                GridViewRow row;
                if (gv_Beneficios.PageIndex == 0)
                {
                    row = gv_Beneficios.Rows[index];
                }
                else
                {
                    Int32 totalPag   = Convert.ToInt32(gv_Beneficios.PageCount);
                    Int32 itemActual = (totalPag - (totalPag - Convert.ToInt32(gv_Beneficios.PageIndex))) * Convert.ToInt32(gv_Beneficios.PageSize);
                    row = gv_Beneficios.Rows[index - itemActual];
                }
                DataKey key = gv_Beneficios.DataKeys[row.RowIndex];

                // Creo una ListItem
                ListItem beneficio = new ListItem();
                ListItem documento = new ListItem();

                beneficio.Text = Server.HtmlDecode(row.Cells[2].Text);
                documento.Text = Server.HtmlDecode(row.Cells[7].Text);

                // Obtengo el id de la entidad que se esta seleccionando
                DataBoundControl nroBenef = (DataBoundControl)gv_Beneficios.Rows[index].FindControl("beneficio");
                DataBoundControl nroDoc   = (DataBoundControl)gv_Beneficios.Rows[index].FindControl("nroDoc");


                DatosPersonaBenef datosPersonaBenef = Servicios.TraerDatosPersonaBenef(long.Parse(beneficio.Text));
                OtrosDatosBenef   otrosDatosBenef   = Servicios.TraerOtrosDatosBenef(long.Parse(beneficio.Text));
                RUBConceptosTot[] datosConceptos    = Servicios.ObtenerTodosConceptos(long.Parse(beneficio.Text));

                if (datosPersonaBenef.error.codError == 999 && otrosDatosBenef.error.codError == 999)
                {
                    this.Alertar("Error en el servicio. No se encontraron datos para el beneficio seleccionado");
                    log.Error(string.Format("No hay datos para el beneficio ingresado -> Error:{0}->", System.Diagnostics.TraceEventType.Error));
                    return;
                }
                else
                {
                    if (datosPersonaBenef.error.codError == 0 || otrosDatosBenef.error.codError == 0)
                    {
                        try
                        {
                            //cargo datos
                            CargarDatosPersona(datosPersonaBenef);
                            CargarDatosBeneficio(datosPersonaBenef);
                            CargarDatosAdicionales(otrosDatosBenef, decimal.Parse(documento.ToString()), decimal.Parse(beneficio.ToString()));
                            if (datosConceptos != null)
                            {
                                CargarConceptos(datosConceptos);
                            }
                            divDatosPersona.Style.Add("display", "block");
                            gv_Beneficios.Enabled             = false;
                            this.btnLimpiarResultado.Disabled = true;
                            divResultados.Style.Add("display", "block");
                            divCollapseBeneficios.Attributes.Add("class", "panel-info panel-collapse collapse");
                            divPrimarioBenef.Attributes.Add("class", "panel panel-info");
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    else
                    {   // dio otro error diferente a 999
                        this.Alertar(datosPersonaBenef.error.mensajeError);
                        log.Error(string.Format("No hay datos para el beneficio ingresado -> Error:{0}->", System.Diagnostics.TraceEventType.Error));
                        return;
                    }
                }
            }
        }
コード例 #32
0
 public static void EnableModelBindingExtensions(this DataBoundControl control)
 {
     control.CreatingModelDataSource += (s, e) => e.ModelDataSource = new ExtendedModelDataSource(control);
 }