コード例 #1
0
        private void BindToDataTable(RadTreeView treeView)
        {
            SqlConnection  connection = new SqlConnection(Properties.Settings.Default.NwindConnectionString);
            SqlDataAdapter adapter    = new SqlDataAdapter("select CategoryID, CategoryName, Description from Categories", connection);
            DataTable      dataTable  = new DataTable();

            adapter.Fill(dataTable);
            treeView.DataTextField  = "CategoryName";
            treeView.DataFieldID    = "CategoryID";
            treeView.DataValueField = "Description";
            treeView.DataSource     = dataTable;
            treeView.DataBind();
        }
コード例 #2
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        public void BindData()
        {
            rfvRequirementSeverityOfExposures.ErrorMessage = _validationErrorMessage;

            _radRequirementSeverityOfExposureTreeView = ((RadTreeView)radRequirementSeverityOfExposures.Items[0].FindControl("radRequirementSeverityOfExposureTreeView"));

            _radRequirementSeverityOfExposureTreeView.Nodes.Clear();

            if (ShowEmpty)
            {
                radRequirementSeverityOfExposures.EmptyMessage = EmptyItemText;
            }
            if (_validationGroup != String.Empty)
            {
                rfvRequirementSeverityOfExposures.ValidationGroup = _validationGroup;
                rfvRequirementSeverityOfExposures.Enabled         = true;
            }
            else
            {
                rfvRequirementSeverityOfExposures.Enabled = false;
            }

            var requirementSeverityOfExposures = _dataManager.RequirementSeverityOfExposure.SelectHierarchy(CurrentUser.Instance.SiteID, RequirementTypeId);

            _radRequirementSeverityOfExposureTreeView.DataSource        = requirementSeverityOfExposures;
            _radRequirementSeverityOfExposureTreeView.DataTextField     = "Title";
            _radRequirementSeverityOfExposureTreeView.DataFieldID       = "ID";
            _radRequirementSeverityOfExposureTreeView.DataValueField    = "ID";
            _radRequirementSeverityOfExposureTreeView.DataFieldParentID = "ParentID";
            _radRequirementSeverityOfExposureTreeView.DataBind();

            if (_selectedCategoryId != Guid.Empty)
            {
                var selectedCategory = _dataManager.RequirementSeverityOfExposure.SelectById(_selectedCategoryId);

                radRequirementSeverityOfExposures.Items[0].Text  = selectedCategory.Title;
                radRequirementSeverityOfExposures.Items[0].Value = _selectedCategoryId.ToString();
                radRequirementSeverityOfExposures.SelectedValue  = _selectedCategoryId.ToString();

                RadTreeNode rtn = _radRequirementSeverityOfExposureTreeView.FindNodeByValue(_selectedCategoryId.ToString());
                rtn.Expanded = true;
                rtn.Selected = true;
                rtn.ExpandParentNodes();
            }
        }
コード例 #3
0
    private static void BindToIEnumerable(RadTreeView treeView)
    {
        List <SiteDataItem> siteData = new List <SiteDataItem>();

        siteData.Add(new SiteDataItem(1, 0, "Products"));
        siteData.Add(new SiteDataItem(2, 1, "Telerik UI for ASP.NET Ajax"));
        siteData.Add(new SiteDataItem(3, 1, "Telerik UI for Silverlight"));
        siteData.Add(new SiteDataItem(4, 2, "RadGrid"));
        siteData.Add(new SiteDataItem(5, 2, "RadScheduler"));
        siteData.Add(new SiteDataItem(6, 2, "RadEditor"));
        siteData.Add(new SiteDataItem(7, 3, "RadGrid"));
        siteData.Add(new SiteDataItem(8, 3, "RadMenu"));
        siteData.Add(new SiteDataItem(9, 3, "RadEditor"));
        siteData.Add(new SiteDataItem(10, 9, "RadEditor1"));
        siteData.Add(new SiteDataItem(11, 9, "RadEditor1"));
        treeView.DataTextField     = "Text";
        treeView.DataFieldID       = "ID";
        treeView.DataFieldParentID = "ParentID";
        treeView.DataSource        = siteData;
        treeView.DataBind();
    }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: PongNT/SandBox
        private void FillTreeView(RadTreeView tv, bool withUrl)
        {
            Car[] cars = new Car[] {
                new Car("Porsche Carrera 1", 79100, "http://www.google.com/search?q=Porsche", null),
                new Car("Ferrari F430", 229955, "http://www.google.com/search?q=Ferrari", null),
                new Car("Aston Martin DB9", 168000, "http://www.google.com/search?q=AstonMartin", null),
                new Car("Porsche Carrera 1-1", 79100, "http://www.google.com/search?q=Porsche", null),
                new Car("Porsche Carrera 1-2", 79100, "http://www.google.com/search?q=Porsche", null),
            };
            cars[3].Parent = cars[0];
            cars[4].Parent = cars[0];

            tv.DataSource        = cars;
            tv.DataTextField     = "Name";
            tv.DataFieldID       = "Name";
            tv.DataFieldParentID = "ParentName";
            tv.DataValueField    = "Price";
            if (withUrl)
            {
                tv.DataNavigateUrlField = "URL";
            }
            tv.DataBind();
        }
コード例 #5
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        public void BindData()
        {
            _radProductCategoryTreeView = ((RadTreeView)radCategories.Items[0].FindControl("radProductCategoryTreeView"));

            _radProductCategoryTreeView.Nodes.Clear();

            if (ShowEmpty)
            {
                radCategories.EmptyMessage = EmptyItemText;
            }
            if (_validationGroup != String.Empty)
            {
                rfvCategories.ValidationGroup = _validationGroup;
                rfvCategories.Enabled         = true;
            }
            else
            {
                rfvCategories.Enabled = false;
            }

            var productCategories     = dataManager.ProductCategory.SelectHierarchy(SiteID).ToList();
            var publicationCategories = dataManager.PublicationCategory.SelectHierarchy(SiteID);

            if (SelectDefault && _selectedCategoryId == Guid.Empty)
            {
                switch (CategoryType)
                {
                case "Product":
                    SelectedCategoryId = productCategories.Where(pc => pc.IsDefault).Select(pc => pc.ID).FirstOrDefault();
                    break;

                case "Publication":
                    SelectedCategoryId = publicationCategories.Where(pc => pc.IsDefault).Select(pc => pc.ID).FirstOrDefault();
                    break;
                }
            }

            switch (CategoryType)
            {
            case "Product":
                _radProductCategoryTreeView.DataSource = productCategories;
                break;

            case "Publication":
                _radProductCategoryTreeView.DataSource = publicationCategories;
                break;
            }

            _radProductCategoryTreeView.DataTextField     = "Title";
            _radProductCategoryTreeView.DataFieldID       = "ID";
            _radProductCategoryTreeView.DataValueField    = "ID";
            _radProductCategoryTreeView.DataFieldParentID = "ParentID";
            _radProductCategoryTreeView.DataBind();

            if (_selectedCategoryId != Guid.Empty)
            {
                switch (CategoryType)
                {
                case "Product":
                    var selectedCategory = dataManager.ProductCategory.SelectById(_selectedCategoryId);
                    radCategories.Items[0].Text = selectedCategory.Title;
                    break;

                case "Publication":
                    var selectedCategory2 = dataManager.PublicationCategory.SelectById(_selectedCategoryId);
                    radCategories.Items[0].Text = selectedCategory2.Title;
                    break;
                }

                radCategories.Items[0].Value = _selectedCategoryId.ToString();

                radCategories.SelectedValue = _selectedCategoryId.ToString();

                RadTreeNode rtn = _radProductCategoryTreeView.FindNodeByValue(_selectedCategoryId.ToString());
                rtn.Expanded = true;
                rtn.Selected = true;
                rtn.ExpandParentNodes();
            }
        }
コード例 #6
0
        private void BindToDataSet(RadTreeView treeView, bool clearError)
        {
            if (clearError)
            {
                //lblMsg.Text = "";
            }
            try
            {
                string treeQuery = " select Concat(\'C-\',ic.ItemCategoryID) as Id, NULL as ParentId, ic.ItemCategoryName as Name ";
                treeQuery += " from ItemCategory as ic ";
                treeQuery += " union ";
                treeQuery += " select Concat(\'S-\',isc.SubCategoryID) as Id, Concat(\'C-\',isc.CategoryID) as ParentId, isc.SubCategoryName as Name ";
                treeQuery += " from ItemSubCategory as isc ";
                treeQuery += " where isc.CategoryID is not null and isc.CategoryID in (select ItemCategoryID from ItemCategory) ";
                treeQuery += " union ";
                treeQuery += " select Concat(\'I-\',ii.ItemID) as Id, Concat(\'S-\',ii.SubCategoryID) as ParentId, ii.ItemName as Name ";
                treeQuery += " from ItemInfo as ii ";
                treeQuery += " where ii.SubCategoryID in ";
                treeQuery += " ( ";
                treeQuery += " select sc.SubCategoryID from ItemSubCategory sc left join ItemCategory c ";
                treeQuery += " on sc.CategoryID = c.ItemCategoryID ";
                treeQuery += " ) ";

                //SqlDataAdapter adapter = new SqlDataAdapter(treeQuery,
                //        "Data Source=10.12.1.2;Initial Catalog=PSMS;User Id=psms;Password=psms;Connection Timeout=0;");
                //DataTable links = new DataTable();
                //adapter.Fill(links);

                //sqlCmd = new SqlCommand(treeQuery);
                //DataTable itemTree = sLink.GetData(sqlCmd);
                DataTable dt = am.DataAccess.RecordSet(treeQuery, new string[] { });
                if (dt != null && dt.Rows.Count > 0)
                {
                    treeView.DataTextField = "Name";
                    treeView.DataValueField = "Id";
                    treeView.DataFieldID = "Id";
                    treeView.DataFieldParentID = "ParentId";

                    treeView.DataSource = dt;
                    treeView.DataBind();
                }
                ResetRecord(clearError, false, false);
            }
            catch (Exception ex)
            {
                //lblMsg.Text = "Error: " + ex.Message;
            }
            finally
            {
                //if (sqlCmd != null)
                //    sqlCmd.Dispose();
            }
        }
コード例 #7
0
        /// <summary>
        /// Loads and binds the list of standard outline tree on right hand side
        /// </summary>
        protected void BindStandardTreeGeneral(ref RadTreeView objtree, bool applyStandardFilter = false)
        {
            if (selectedAssessment == null)
            {
                selectedAssessment = (Assessment)Cache.Get(this.CacheKey);

                if (selectedAssessment == null)
                {
                    LoadAssessmentObject();
                }
            }
            string standardSet = OutlineStandardSet.SelectedItem.Text;//.Replace("Set: ", "");
            //dtItemBank itemBanks = ItemBankMasterList.GetItemBanksForStandardSearch(SessionObject.LoggedInUser, selectedAssessment.TestCategory);
            DataTable dtStandards;
            if (applyStandardFilter)
            {
                dtStandards = GetStandardsData();
                //dtStandards = Thinkgate.Base.Classes.Standards.GetStandardsByCurriculum(null, null, null, null, selectedAssessment.TestCategory, currUserID, selectedAssessment.currCourseID, itemBanks);
            }
            else
            {
                dtStandards = GetStandardsData(standardSet);
            }
            if (!dtStandards.Columns.Contains("StandardNameWithCount"))
            {
                dtStandards.Columns.Add(new DataColumn("StandardNameWithCount", typeof(string)));
            }

            DataView dv = new DataView(dtStandards);
            if (applyStandardFilter)
            {
                if (SessionObject.LoggedInUser.StandardFilters.Values.Count > 0)
                {
                    // Ben has this data broken so I'm just waiting
                    dv.RowFilter = "StandardID in (" + SessionObject.LoggedInUser.StandardFilters.Values.First() + ")";
                }
                // targetData = dtStandards.Select("StandardID in (" + SessionObject.LoggedInUser.StandardFilters + ")");
            }
            else
            {
                dv.RowFilter = "Standard_Set = '" + standardSet + "'";

            }
            foreach (DataRowView r in dv)
            {
                if (r["ParentID"].Equals(0))
                {
                    r["ParentID"] = DBNull.Value;
                }
                r["StandardNameWithCount"] = (applyStandardFilter ? r["FullStandardName"] : r["StandardName"]) + " (" + r["ItemCount"].ToString() + ")";
                if (applyStandardFilter)
                {
                    r["ParentID"] = DBNull.Value;   // this is temporary until I can figure out how to handle nonexistant parents when filtered
                }
            }

            objtree.DataSource = dv;
            objtree.DataBind();
        }