Beispiel #1
0
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of contact information from the Contacts
        /// table, and then databind the results to a DataGrid
        /// server control.  It uses the Rainbow.ContactsDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            //MH: Added  01/10/2003 [[email protected]]
            //set visibility of the columns
            myDataGrid.Columns[3].Visible = (Settings["SHOW_COLUMN_EMAIL"] != null)
                                                ? bool.Parse(Settings["SHOW_COLUMN_EMAIL"].ToString())
                                                : true;
            myDataGrid.Columns[4].Visible = (Settings["SHOW_COLUMN_CONTACT1"] != null)
                                                ? bool.Parse(Settings["SHOW_COLUMN_CONTACT1"].ToString())
                                                : true;
            myDataGrid.Columns[5].Visible = (Settings["SHOW_COLUMN_CONTACT2"] != null)
                                                ? bool.Parse(Settings["SHOW_COLUMN_CONTACT2"].ToString())
                                                : true;
            myDataGrid.Columns[6].Visible = (Settings["SHOW_COLUMN_FAX"] != null)
                                                ? bool.Parse(Settings["SHOW_COLUMN_FAX"].ToString())
                                                : true;
            myDataGrid.Columns[7].Visible = (Settings["SHOW_COLUMN_ADDRESS"] != null)
                                                ? bool.Parse(Settings["SHOW_COLUMN_ADDRESS"].ToString())
                                                : true;
            //MH: End

            if (Page.IsPostBack == false)
            {
                sortField     = "Name";
                sortDirection = "ASC";
                if (sortField == "DueDate")
                {
                    sortDirection = "DESC";
                }
                ViewState["SortField"]     = sortField;
                ViewState["SortDirection"] = sortDirection;
            }
            else
            {
                sortField     = (string)ViewState["SortField"];
                sortDirection = (string)ViewState["sortDirection"];
            }

            myDataView = new DataView();

            // Obtain contact information from Contacts table
            // and bind to the DataGrid Control
            ContactsDB contacts = new ContactsDB();

            DataSet contactData = contacts.GetContacts(ModuleID, Version);

            myDataView = contactData.Tables[0].DefaultView;

            if (!Page.IsPostBack)
            {
                myDataView.Sort = sortField + " " + sortDirection;
            }

            BindGrid();
        }
Beispiel #2
0
        public List <Contact> GetListOfContacts()
        {
            ContactsDB contactsDB = new ContactsDB();

            return(contactsDB.GetContacts());
        }