ParameterDataSourceExpression.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / WebControls / Expressions / ParameterDataSourceExpression.cs / 1305376 / ParameterDataSourceExpression.cs

                            #if ORYX_VNEXT 
namespace Microsoft.Web.Data.UI.WebControls.Expressions {
    using System.Web;
    using System.Web.UI;
#else 
namespace System.Web.UI.WebControls.Expressions {
#endif 
    using System; 
    using System.Collections.Generic;
    using System.Collections.Specialized; 
    using System.Linq.Expressions;
    using System.Web.UI.WebControls;

    [ 
    PersistChildren(false),
    ParseChildren(true, "Parameters") 
    ] 
    public abstract class ParameterDataSourceExpression : DataSourceExpression {
        private ParameterCollection _parameters; 

        [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
        public ParameterCollection Parameters {
            get { 
                if (_parameters == null) {
                    _parameters = new ParameterCollection(); 
                    _parameters.ParametersChanged += new EventHandler(OnParametersChanged); 
                }
                return _parameters; 
            }
        }

        internal virtual IDictionary GetValues() { 
            return Parameters.ToDictionary(Context, Owner);
        } 
 
        public override void SetContext(Control owner, HttpContext context, IQueryableDataSource dataSource) {
            base.SetContext(owner, context, dataSource); 

            owner.Page.LoadComplete += new EventHandler(OnPageLoadComplete);
        }
 
        private void OnParametersChanged(object sender, EventArgs e) {
            if (DataSource != null) { 
                DataSource.RaiseViewChanged(); 
            }
        } 

        private void OnPageLoadComplete(object sender, System.EventArgs e) {
            Parameters.UpdateValues(Context, Owner);
        } 

        protected override object SaveViewState() { 
            Pair p = new Pair(); 
            p.First = base.SaveViewState();
            p.Second = DataSourceHelper.SaveViewState(_parameters); 
            return p;
        }

        protected override void LoadViewState(object savedState) { 
            Pair p = (Pair)savedState;
            base.LoadViewState(p.First); 
            if (p.Second != null) { 
                ((IStateManager)Parameters).LoadViewState(p.Second);
            } 
        }

        protected override void TrackViewState() {
            base.TrackViewState(); 
            DataSourceHelper.TrackViewState(_parameters);
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK