示例#1
0
        /// <summary>
        /// Display all capabilities
        /// </summary>
        private void UpdateDataView()
        {
            string sSql = string.Empty;

            webTab.Visible = false;
            string filter = txtFilter.Text;

            if (filter != string.Empty)
            {
                string cleanFilter = filter.Replace("'", "''").ToLower();
                cleanFilter = cleanFilter.Replace("[", "[[]");
                cleanFilter = cleanFilter.Replace("_", "[_]");
                cleanFilter = cleanFilter.Replace("%", "[%]");

                sSql += " LOWER(Name) like '%" + cleanFilter + "%' ";
                sSql += " OR LOWER(Description) like '%" + cleanFilter + "%' ";
            }

            using (CapabilityList capabilities = Capability.GetAll(sSql))
            {
                if (capabilities != null)
                {
                    if (capabilities.Count > 0)
                    {
                        dg.DataSource = capabilities;
                        Utils.InitGridSort(ref dg);
                        dg.DataBind();

                        dg.Visible          = true;
                        lbNoresults.Visible = false;
                    }
                    else
                    {
                        if (txtFilter.Text.Length > 0)
                        {
                            lbNoresults.Text = "No record match your search (" + txtFilter.Text + ")";
                        }

                        dg.Visible          = false;
                        lbNoresults.Visible = true;
                    }
                }
                else
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = "Error: a system error occurred";
                    lbError.Visible  = true;
                }
            }
        }