コード例 #1
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            List<SiteNav> lstContents = new List<SiteNav>();
            int iTake = 10;
            int iTotal = -1;

            phResults.Visible = true;
            sSearchTerm = txtSearchTerm.Text;
            hdnSelectedItem.Value = "";

            GeneralUtilities.BindDataBoundControl(gvWidgets, null);

            if (!string.IsNullOrEmpty(gvPages.DefaultSort)) {
                int pos = gvPages.DefaultSort.LastIndexOf(" ");
                sSortFld = gvPages.DefaultSort.Substring(0, pos).Trim();
                sSortDir = gvPages.DefaultSort.Substring(pos).Trim();
            }

            bool bLimit = chkActive.Checked;

            using (SiteNavHelper navHelper = new SiteNavHelper()) {
                if (!string.IsNullOrEmpty(sSearchTerm)) {
                    iTotal = navHelper.GetSiteSearchCount(SiteData.CurrentSiteID, sSearchTerm, bLimit);
                    lstContents = navHelper.GetLatestContentSearchList(SiteData.CurrentSiteID, sSearchTerm, bLimit, iTake, 0, sSortFld, sSortDir);
                }
            }

            if (iTotal > 0) {
                if (iTotal > lstContents.Count) {
                    litResults.Text = String.Format("Showing {0} of {1} total results", lstContents.Count, iTotal);
                } else {
                    litResults.Text = String.Format("Showing {0} results", lstContents.Count);
                }
            }

            GeneralUtilities.BindDataBoundControl(gvPages, lstContents);
        }