This is a migrated thread and some comments may be shown as answers.

RadComboBox Population problems

1 Answer 63 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Goat_
Top achievements
Rank 1
Goat_ asked on 24 Apr 2013, 10:44 AM
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

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 29 Apr 2013, 10:42 AM
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.
Tags
General Discussions
Asked by
Goat_
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or