예제 #1
0
        /// <summary>
        /// 将数据源dataSource处理成IEnumerable类型的数据源
        /// </summary>
        /// <param name="ctr">需要处理数据源的控件</param>
        /// <param name="dataSource">需要处理的数据源</param>
        /// <returns>处理结果</returns>
        /// <remarks>将数据源dataSource处理成IEnumerable类型的数据源</remarks>
        public static IEnumerable GetDataSourceResult(Control ctr, object dataSource)
        {
            DataBoundControlInternal dataCtr = GetChildDataBoundControl(ctr);

            dataCtr.DataSourceID = string.Empty;
            dataCtr.DataSource   = dataSource;
            dataCtr.DataBind();

            return(dataCtr.DataSourceResult);
        }
예제 #2
0
        /// <summary>
        /// 将数据源控件处理成IEnumerable类型的数据源
        /// </summary>
        /// <param name="ctr">需要处理数据源的控件</param>
        /// <param name="dataSourceID">需要处理的数据源控件ID</param>
        /// <returns>处理结果</returns>
        /// <remarks>将数据源控件处理成IEnumerable类型的数据源</remarks>
        public static IEnumerable GetDataSourceResult(Control ctr, string dataSourceID)
        {
            DataBoundControlInternal dataCtr = GetChildDataBoundControl(ctr);

            dataCtr.DataSource   = null;
            dataCtr.DataSourceID = dataSourceID;
            dataCtr.DataBind();

            return(dataCtr.DataSourceResult);
        }
예제 #3
0
        private static DataBoundControlInternal GetChildDataBoundControl(Control ctr)
        {
            string ctrID = ctr.ID + "__DataBoundControlInternal";
            DataBoundControlInternal dataCtr = (DataBoundControlInternal)ctr.FindControl(ctrID);

            if (dataCtr == null)
            {
                dataCtr    = new DataBoundControlInternal();
                dataCtr.ID = ctrID;
                ctr.Controls.Add(dataCtr);
            }

            return(dataCtr);
        }