private void GridViewUsersBind()
        {
            try
            {
                usersList          = SQLProcedures.GetUsers();
                gvUsers.DataSource = usersList;
                gvUsers.DataBind();
                gvUsers.PagerSettings.FirstPageText    = "<<";
                gvUsers.PagerSettings.PreviousPageText = "<";
                gvUsers.PagerSettings.NextPageText     = ">";
                gvUsers.PagerSettings.LastPageText     = ">>";
                gvUsers.DataBind();

                lblError.Text = string.Empty;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
        protected void btnExportUsers_Click(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
                               "attachment;filename=Users.csv");
            Response.Charset     = "";
            Response.ContentType = "application/text";

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < gvUsers.Columns.Count; i++)
            {
                sb.Append(gvUsers.Columns[i].HeaderText + ',');
            }
            sb.Append("\r\n");

            usersList = SQLProcedures.GetUsers();
            usersList.ForEach(u => sb.Append(u.ToString()).Append("\r\n"));

            Response.Output.Write(sb.ToString());
            Response.Flush();
            Response.End();
        }
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            filteredUsersList.Clear();

            usersList         = SQLProcedures.GetUsers();
            filteredUsersList = usersList.ToList();

            if (cblSex.Items.OfType <ListItem>().Any(i => i.Selected))
            {
                foreach (ListItem item in cblSex.Items)
                {
                    if (!item.Selected)
                    {
                        foreach (User u in usersList)
                        {
                            if (u.Sex == item.Text)
                            {
                                filteredUsersList.Remove(u);
                            }
                        }
                    }
                }
            }

            if (cbActivityLevel.Items.OfType <ListItem>().Any(i => i.Selected))
            {
                foreach (ListItem item in cbActivityLevel.Items)
                {
                    if (!item.Selected)
                    {
                        foreach (User u in usersList)
                        {
                            if (u.ActivityLevel.ToString() == item.Text)
                            {
                                filteredUsersList.Remove(u);
                            }
                        }
                    }
                }
            }

            if (cbDiabetesType.Items.OfType <ListItem>().Any(i => i.Selected))
            {
                foreach (ListItem item in cbDiabetesType.Items)
                {
                    if (!item.Selected)
                    {
                        foreach (User u in usersList)
                        {
                            if (u.DiabetesType.ToString() == item.Text)
                            {
                                filteredUsersList.Remove(u);
                            }
                        }
                    }
                }
            }

            gvUsers.DataSource = filteredUsersList;
            gvUsers.DataBind();
        }