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

RadComboBox Population problems

1 Answer 43 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Goat_
Top achievements
Rank 1
Goat_ asked on 24 Apr 2013, 12:46 PM
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
Goat_
Top achievements
Rank 1
answered on 24 Apr 2013, 01:33 PM
I found the problem, Just had to set AutoPostBack = true
Tags
ComboBox
Asked by
Goat_
Top achievements
Rank 1
Answers by
Goat_
Top achievements
Rank 1
Share this question
or