コード例 #1
0
    private void UpdateDataView()
    {
        string sSql   = "GroupId = " + containerGroupId;
        string filter = txtFilter.Text;

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

            sSql += " AND (LOWER(Tag) like '%" + cleanFilter + "%'";
            sSql += " OR LOWER(Name) like '%" + cleanFilter + "%'";
            sSql += " OR LOWER(Definition) like '%" + cleanFilter + "%'";
            sSql += " OR LOWER(DataType) like '%" + cleanFilter + "%'";
            sSql += " OR LOWER(ContainerType) like '%" + cleanFilter + "%')";
        }

        using (HyperCatalog.Business.ContainerList HCContainers = HyperCatalog.Business.Container.GetAll(sSql, "Tag"))
        {
            if (HCContainers != null)
            {
                if (HCContainers.Count > 0)
                {
                    dg.DataSource = HCContainers;
                    Utils.InitGridSort(ref dg);
                    dg.DataBind();

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

                    dg.Visible          = false;
                    lbNoresults.Visible = true;
                }
            }
        }
    }
コード例 #2
0
        protected void dg_DataBinding(object sender, System.EventArgs e)
        {
            panelGrid.Visible = true;
            panelTab.Visible  = false;

            string groupId = ddlContainerGroup.SelectedValue.Trim();

            lbTitle.Text = "Container list";

            string sSql = String.Empty;

            if (groupId.Trim() != string.Empty)
            {
                if (groupId != "-1")
                {
                    sSql += "GroupId =" + groupId;
                }
                lbTitle.Text = ddlContainerGroup.Items[ddlContainerGroup.SelectedIndex].Text;
            }

            string filter = txtFilter.Text;

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

                sSql += " (LOWER(Tag) like '%" + cleanFilter + "%'";
                sSql += " OR LOWER(Name) like '%" + cleanFilter + "%'";
                sSql += " OR LOWER(Definition) like '%" + cleanFilter + "%')";
            }
            using (HyperCatalog.Business.ContainerList HCContainers = HyperCatalog.Business.Container.GetAll(sSql, "Tag"))
            {
                if (HCContainers != null)
                {
                    if (HCContainers.Count > 0)
                    {
                        dg.DataSource = HCContainers;

                        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;
                    }
                    lbTitle.Text = lbTitle.Text + " (" + HCContainers.Count.ToString() + ")";
                }
            }
        }