DataBoundControlParameterTarget.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 / DynamicData / DynamicData / DataBoundControlParameterTarget.cs / 1305376 / DataBoundControlParameterTarget.cs

                            namespace System.Web.DynamicData { 
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web.UI; 
    using System.Web.UI.WebControls;
    using System.Globalization; 
 
    internal class DataBoundControlParameterTarget : IControlParameterTarget {
        private Control _control; 
        public DataBoundControlParameterTarget(Control control) {
            if (control == null) {
                throw new ArgumentNullException("control");
            } 
            _control = control;
        } 
 
        public MetaTable Table {
            get { 
                return _control.FindMetaTable();
            }
        }
 
        public MetaColumn FilteredColumn {
            get { 
                return null; 
            }
        } 

        public string GetPropertyNameExpression(string columnName) {
            // Get the DataKeyPropertyAttribute and use that as the to get the correct property name expression
            DataKeyPropertyAttribute attribute = _control.GetType().GetCustomAttributes(true).OfType().FirstOrDefault(); 
            if ((attribute != null) && !String.IsNullOrEmpty(attribute.Name)) {
                return attribute.Name + String.Format(CultureInfo.InvariantCulture, "['{0}']",  columnName); 
            } 
            //
            return String.Empty; 
        }
    }
}

// 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