private void txtSearch_OnValueChanged(object sender, EventArgs e)
        {
            // Get the keywords
            string keywords = txtSearch.Text;

            // Filter the items based on keywords
            if (keywords != null)
            {
                // Use search method to display items
                DataTable dt = dal.Search(keywords);
                dgvResponders.DataSource = dt;

                DataView dv = dt.DefaultView;
                dv.Sort = "IDNumber";
                DataTable sortedDT = dv.ToTable();
            }
            else
            {
                // Use select method to display all items
                DataTable dt = dal.Select();
                dgvResponders.DataSource = dt;

                DataView dv = dt.DefaultView;
                dv.Sort = "IDNumber";
                DataTable sortedDT = dv.ToTable();
            }
        }
Exemple #2
0
        private void FillRespondersDatagridview()
        {
            RespondersDAL dal = new RespondersDAL();

            // View the data from datagridview
            DataTable dt = dal.Select();

            respondersCustomControl1.dgvResponders.DataSource = dt;

            DataView dv = dt.DefaultView;

            dv.Sort = "IDNumber";
            DataTable sortedDT = dv.ToTable();

            respondersCustomControl1.dgvResponders.Columns[0].Visible  = false;
            respondersCustomControl1.dgvResponders.Columns[12].Visible = false;

            // Change Header Name of datagridview
            respondersCustomControl1.dgvResponders.Columns[1].HeaderText  = "ID Number";
            respondersCustomControl1.dgvResponders.Columns[10].HeaderText = "Birthdate (yyyy-MM-dd)";
        }