RadComboBox Population problems

2 posts, 0 answers
  1. Goat_
    Goat_ avatar
    11 posts
    Member since:
    Apr 2013

    Posted 24 Apr 2013 Link to this post

    Hi guys,

    I have 2 RadComboBoxes, the First ComboBox 'ProductGroups' gets populated directly from a SQL database, once i have made a selection from the 'ProductGroups' ComboBox the Second RadComboBox 'Products' should be populated automatically Only with the data that is related to the selectedValue made from the First ComboBox. So If an item was NOT selected from the first comboBox the second ComboBox Will not be populated.

    ProductGroups (1st) box populates properly i am just having issues populating the second Box with data, the Second ComboBox does not have any TreeViews inside of it, its just single item select.

    Here are my 2 Classes i am using

    public class ProductGroup
        {
            #region Properties
     
            [Key]
            public int ProductGroupID { get; set; }
            
            [Column("ProductGroup")]
            public string ProductGroupName { get; set; }
            [Column]
            public bool Active { get; set; }
     
            #endregion
     
     
            #region Methods
            public static IEnumerable<ProductGroup> GetActiveProductGroups()
            {
                iThNkContext db = new iThNkContext();
     
                var ProductGroupList = db.ProductGroups.Where(grp => grp.Active == true).OrderBy(p => p.ProductGroupName);
     
                return ProductGroupList.ToList();
            }
            #endregion
        }


    public class Product
        {
            #region Properties
     
            [Key]
            public int ProductID { get; set; }
             
            [Column("Product")]
            public string ProductName { get; set; }
            [Column]
            public bool Active { get; set; }
            [Column]
            public int ProductGroupID { get; set; }
     
            #endregion
     
            #region Methods
            // Checks for active products and will only return active ones in the form of a list.
                public static IEnumerable<Product> GetActiveProducts(int productGroupID)
                {
     
                        iThNkContext db = new iThNkContext();
     
                        var productList = db.Products.Where(p => p.ProductGroupID == productGroupID && p.Active == true).OrderBy(p => p.ProductName);
     
                        return productList.ToList();
     
                }
            #endregion
     
        }


    And here is the other code i am using to do the actual populating

    protected void cboProductGroup_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
            {
                cboProductGroup.DataSource = iThNkPOCO.Models.ProductGroup.GetActiveProductGroups();
                cboProductGroup.DataBind();
            }
     
            protected void cboProductGroup_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
            {
                cboProduct.DataSource = iThNkPOCO.Models.Product.GetActiveProducts(Convert.ToInt32(e.Value));
                cboProduct.DataBind();
            }

    I dont get any Errors, the second RadComboBox just isnt populating.

    Thanx in advance
  2. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 29 Apr 2013 Link to this post

    Hi Patrick,

     
    You implement the scenario by following this on-line demo where is explained how to achieve issue without errors. You only have to change the DataSources used according to your scenario. 

    Hope this will be helpful.

    Regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top