using System;
using System.Linq;
using schema = Jhu.Graywulf.Schema;
using System.Web.UI;

namespace CasJobsWeb.schema
{
    public partial class ColumnList : UserControl
    {
        protected schema::IColumns databaseObject;

        public schema::IColumns DatabaseObject
        {
            get { return databaseObject; }
            set
            {
                databaseObject = value;
                if (value == null)
                {
                    listView.DataSource = null;
                    listView.DataBind();
                }
                RefreshForm();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            RefreshForm();
        }

        private void RefreshForm()
        {
            if (databaseObject != null)
            {
                listView.DataSource = databaseObject.Columns.Values.OrderBy(i => i.ID);
                listView.DataBind();
            }
        }
    }
}