Click here to Skip to main content
12,248,978 members (34,051 online)
Click here to Skip to main content

Stats

140.4K views
11.1K downloads
108 bookmarked
Posted

Advanced ASPX GridView Pagination and Data Entities

, 14 Feb 2013 CPOL
ASP.NET based software system skeleton that uses the ASPX GridView control and advanced pagination for displaying a list of data entities loaded from the database, and the ASP.NET AJAX ModalPopupExtender control for creating new entities or for editing entities from the grid.
//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.EntityClient;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

[assembly: EdmSchemaAttribute()]
#region EDM Relationship Metadata

[assembly: EdmRelationshipAttribute("RaGridViewModel", "FK_Contacts_Groups", "Groups", System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(Ra.GridView.Data.Group), "Contacts", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(Ra.GridView.Data.Contact), true)]

#endregion

namespace Ra.GridView.Data
{
    #region Contexts
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    public partial class RaGridViewEntities : ObjectContext
    {
        #region Constructors
    
        /// <summary>
        /// Initializes a new RaGridViewEntities object using the connection string found in the 'RaGridViewEntities' section of the application configuration file.
        /// </summary>
        public RaGridViewEntities() : base("name=RaGridViewEntities", "RaGridViewEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new RaGridViewEntities object.
        /// </summary>
        public RaGridViewEntities(string connectionString) : base(connectionString, "RaGridViewEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new RaGridViewEntities object.
        /// </summary>
        public RaGridViewEntities(EntityConnection connection) : base(connection, "RaGridViewEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        #endregion
    
        #region Partial Methods
    
        partial void OnContextCreated();
    
        #endregion
    
        #region ObjectSet Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Contact> Contacts
        {
            get
            {
                if ((_Contacts == null))
                {
                    _Contacts = base.CreateObjectSet<Contact>("Contacts");
                }
                return _Contacts;
            }
        }
        private ObjectSet<Contact> _Contacts;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Group> Groups
        {
            get
            {
                if ((_Groups == null))
                {
                    _Groups = base.CreateObjectSet<Group>("Groups");
                }
                return _Groups;
            }
        }
        private ObjectSet<Group> _Groups;

        #endregion
        #region AddTo Methods
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Contacts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToContacts(Contact contact)
        {
            base.AddObject("Contacts", contact);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Groups EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToGroups(Group group)
        {
            base.AddObject("Groups", group);
        }

        #endregion
        #region Function Imports
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="id">No Metadata Documentation available.</param>
        public ObjectResult<Contact> GetContactByID(Nullable<global::System.Int32> id)
        {
            ObjectParameter idParameter;
            if (id.HasValue)
            {
                idParameter = new ObjectParameter("id", id);
            }
            else
            {
                idParameter = new ObjectParameter("id", typeof(global::System.Int32));
            }
    
            return base.ExecuteFunction<Contact>("GetContactByID", idParameter);
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="mergeOption"></param>
        /// <param name="id">No Metadata Documentation available.</param>
        public ObjectResult<Contact> GetContactByID(Nullable<global::System.Int32> id, MergeOption mergeOption)
        {
            ObjectParameter idParameter;
            if (id.HasValue)
            {
                idParameter = new ObjectParameter("id", id);
            }
            else
            {
                idParameter = new ObjectParameter("id", typeof(global::System.Int32));
            }
    
            return base.ExecuteFunction<Contact>("GetContactByID", mergeOption, idParameter);
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="pageIndex">No Metadata Documentation available.</param>
        /// <param name="pageSize">No Metadata Documentation available.</param>
        /// <param name="sortBy">No Metadata Documentation available.</param>
        /// <param name="groupID">No Metadata Documentation available.</param>
        /// <param name="count">No Metadata Documentation available.</param>
        public ObjectResult<Contact> GetContactsByFilterPaginated(Nullable<global::System.Int32> pageIndex, Nullable<global::System.Int32> pageSize, global::System.String sortBy, Nullable<global::System.Int32> groupID, ObjectParameter count)
        {
            ObjectParameter pageIndexParameter;
            if (pageIndex.HasValue)
            {
                pageIndexParameter = new ObjectParameter("pageIndex", pageIndex);
            }
            else
            {
                pageIndexParameter = new ObjectParameter("pageIndex", typeof(global::System.Int32));
            }
    
            ObjectParameter pageSizeParameter;
            if (pageSize.HasValue)
            {
                pageSizeParameter = new ObjectParameter("pageSize", pageSize);
            }
            else
            {
                pageSizeParameter = new ObjectParameter("pageSize", typeof(global::System.Int32));
            }
    
            ObjectParameter sortByParameter;
            if (sortBy != null)
            {
                sortByParameter = new ObjectParameter("sortBy", sortBy);
            }
            else
            {
                sortByParameter = new ObjectParameter("sortBy", typeof(global::System.String));
            }
    
            ObjectParameter groupIDParameter;
            if (groupID.HasValue)
            {
                groupIDParameter = new ObjectParameter("groupID", groupID);
            }
            else
            {
                groupIDParameter = new ObjectParameter("groupID", typeof(global::System.Int32));
            }
    
            return base.ExecuteFunction<Contact>("GetContactsByFilterPaginated", pageIndexParameter, pageSizeParameter, sortByParameter, groupIDParameter, count);
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="mergeOption"></param>
        /// <param name="pageIndex">No Metadata Documentation available.</param>
        /// <param name="pageSize">No Metadata Documentation available.</param>
        /// <param name="sortBy">No Metadata Documentation available.</param>
        /// <param name="groupID">No Metadata Documentation available.</param>
        /// <param name="count">No Metadata Documentation available.</param>
        public ObjectResult<Contact> GetContactsByFilterPaginated(Nullable<global::System.Int32> pageIndex, Nullable<global::System.Int32> pageSize, global::System.String sortBy, Nullable<global::System.Int32> groupID, ObjectParameter count, MergeOption mergeOption)
        {
            ObjectParameter pageIndexParameter;
            if (pageIndex.HasValue)
            {
                pageIndexParameter = new ObjectParameter("pageIndex", pageIndex);
            }
            else
            {
                pageIndexParameter = new ObjectParameter("pageIndex", typeof(global::System.Int32));
            }
    
            ObjectParameter pageSizeParameter;
            if (pageSize.HasValue)
            {
                pageSizeParameter = new ObjectParameter("pageSize", pageSize);
            }
            else
            {
                pageSizeParameter = new ObjectParameter("pageSize", typeof(global::System.Int32));
            }
    
            ObjectParameter sortByParameter;
            if (sortBy != null)
            {
                sortByParameter = new ObjectParameter("sortBy", sortBy);
            }
            else
            {
                sortByParameter = new ObjectParameter("sortBy", typeof(global::System.String));
            }
    
            ObjectParameter groupIDParameter;
            if (groupID.HasValue)
            {
                groupIDParameter = new ObjectParameter("groupID", groupID);
            }
            else
            {
                groupIDParameter = new ObjectParameter("groupID", typeof(global::System.Int32));
            }
    
            return base.ExecuteFunction<Contact>("GetContactsByFilterPaginated", mergeOption, pageIndexParameter, pageSizeParameter, sortByParameter, groupIDParameter, count);
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectResult<Group> GetAllGroups()
        {
            return base.ExecuteFunction<Group>("GetAllGroups");
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="mergeOption"></param>
        public ObjectResult<Group> GetAllGroups(MergeOption mergeOption)
        {
            return base.ExecuteFunction<Group>("GetAllGroups", mergeOption);
        }

        #endregion
    }
    

    #endregion
    
    #region Entities
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="RaGridViewModel", Name="Contact")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Contact : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Contact object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        /// <param name="firstName">Initial value of the FirstName property.</param>
        /// <param name="lastName">Initial value of the LastName property.</param>
        public static Contact CreateContact(global::System.Int32 id, global::System.String firstName, global::System.String lastName)
        {
            Contact contact = new Contact();
            contact.ID = id;
            contact.FirstName = firstName;
            contact.LastName = lastName;
            return contact;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ID
        {
            get
            {
                return _ID;
            }
            set
            {
                if (_ID != value)
                {
                    OnIDChanging(value);
                    ReportPropertyChanging("ID");
                    _ID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("ID");
                    OnIDChanged();
                }
            }
        }
        private global::System.Int32 _ID;
        partial void OnIDChanging(global::System.Int32 value);
        partial void OnIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String FirstName
        {
            get
            {
                return _FirstName;
            }
            set
            {
                OnFirstNameChanging(value);
                ReportPropertyChanging("FirstName");
                _FirstName = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("FirstName");
                OnFirstNameChanged();
            }
        }
        private global::System.String _FirstName;
        partial void OnFirstNameChanging(global::System.String value);
        partial void OnFirstNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String LastName
        {
            get
            {
                return _LastName;
            }
            set
            {
                OnLastNameChanging(value);
                ReportPropertyChanging("LastName");
                _LastName = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("LastName");
                OnLastNameChanged();
            }
        }
        private global::System.String _LastName;
        partial void OnLastNameChanging(global::System.String value);
        partial void OnLastNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Email
        {
            get
            {
                return _Email;
            }
            set
            {
                OnEmailChanging(value);
                ReportPropertyChanging("Email");
                _Email = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Email");
                OnEmailChanged();
            }
        }
        private global::System.String _Email;
        partial void OnEmailChanging(global::System.String value);
        partial void OnEmailChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> GroupID
        {
            get
            {
                return _GroupID;
            }
            set
            {
                OnGroupIDChanging(value);
                ReportPropertyChanging("GroupID");
                _GroupID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("GroupID");
                OnGroupIDChanged();
            }
        }
        private Nullable<global::System.Int32> _GroupID;
        partial void OnGroupIDChanging(Nullable<global::System.Int32> value);
        partial void OnGroupIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Phone
        {
            get
            {
                return _Phone;
            }
            set
            {
                OnPhoneChanging(value);
                ReportPropertyChanging("Phone");
                _Phone = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Phone");
                OnPhoneChanged();
            }
        }
        private global::System.String _Phone;
        partial void OnPhoneChanging(global::System.String value);
        partial void OnPhoneChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Note
        {
            get
            {
                return _Note;
            }
            set
            {
                OnNoteChanging(value);
                ReportPropertyChanging("Note");
                _Note = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Note");
                OnNoteChanged();
            }
        }
        private global::System.String _Note;
        partial void OnNoteChanging(global::System.String value);
        partial void OnNoteChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Boolean> Deleted
        {
            get
            {
                return _Deleted;
            }
            set
            {
                OnDeletedChanging(value);
                ReportPropertyChanging("Deleted");
                _Deleted = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Deleted");
                OnDeletedChanged();
            }
        }
        private Nullable<global::System.Boolean> _Deleted;
        partial void OnDeletedChanging(Nullable<global::System.Boolean> value);
        partial void OnDeletedChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("RaGridViewModel", "FK_Contacts_Groups", "Groups")]
        public Group Group
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Group>("RaGridViewModel.FK_Contacts_Groups", "Groups").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Group>("RaGridViewModel.FK_Contacts_Groups", "Groups").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<Group> GroupReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Group>("RaGridViewModel.FK_Contacts_Groups", "Groups");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Group>("RaGridViewModel.FK_Contacts_Groups", "Groups", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="RaGridViewModel", Name="Group")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Group : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Group object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        public static Group CreateGroup(global::System.Int32 id, global::System.String name)
        {
            Group group = new Group();
            group.ID = id;
            group.Name = name;
            return group;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ID
        {
            get
            {
                return _ID;
            }
            set
            {
                if (_ID != value)
                {
                    OnIDChanging(value);
                    ReportPropertyChanging("ID");
                    _ID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("ID");
                    OnIDChanged();
                }
            }
        }
        private global::System.Int32 _ID;
        partial void OnIDChanging(global::System.Int32 value);
        partial void OnIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                OnNameChanging(value);
                ReportPropertyChanging("Name");
                _Name = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("Name");
                OnNameChanged();
            }
        }
        private global::System.String _Name;
        partial void OnNameChanging(global::System.String value);
        partial void OnNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Description
        {
            get
            {
                return _Description;
            }
            set
            {
                OnDescriptionChanging(value);
                ReportPropertyChanging("Description");
                _Description = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Description");
                OnDescriptionChanged();
            }
        }
        private global::System.String _Description;
        partial void OnDescriptionChanging(global::System.String value);
        partial void OnDescriptionChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("RaGridViewModel", "FK_Contacts_Groups", "Contacts")]
        public EntityCollection<Contact> Contacts
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Contact>("RaGridViewModel.FK_Contacts_Groups", "Contacts");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Contact>("RaGridViewModel.FK_Contacts_Groups", "Contacts", value);
                }
            }
        }

        #endregion
    }

    #endregion
    
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Raul Iloc
Program Manager
Romania Romania
I am Project Manager with about 20 years working experience in software development and about 15 years as Software Project Manager and Architect.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 15 Feb 2013
Article Copyright 2010 by Raul Iloc
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid