locked
insert items into checkboxlist without duplications RRS feed

  • Question

  • Hi Guys,

    I need your help please, thanks in advance,

    I have 2 tabs each one of them contains unbound checklistbox, example Checklistbox name Chapp contains all user application and Chshared have all shared drive names. I have another list I created that has similar or different items  I want to add items of this list to each appropriate checkboxlist without creating any duplicates. example

    Chapp list has

    adobe

    Office

    Chshared has 

    c: @drive

    d: @drive

    the new list

    Adobe

    c:@drive.

    k:@drive

    public void loadapp()
            {
    
                IEnumerable<ConcreteDataObject> productCategories = concreteDataApi.FindAllByType("ProductCategory")
                      .Where(c => c.Name == TextBoxDepartment.Text.ToString());
    
                using (ProductManagementDataContext ctx = DataContextFactory.Create<ProductManagementDataContext>())
    
                    foreach (ConcreteDataObject productCategory in productCategories)
                    {
                        IQueryable<Product> q = from p in ctx.Products
                                                where p.CategoryId == productCategory.Id
                                                select p;
    
    
                        foreach (var productItems in q)
                        {
    
                            if (!chapp.Items.Cast<ListItem>().Where(r => r.Selected).Any(m => m.Text == productItems.Name && !productItems.Name.Contains("@")))
    
                                // 
    
                                chapp.Items.Add(productItems.Name);
                            else if ((chShared.Items.Cast<ListItem>().Where(r => r.Selected).Any(m => m.Text == productItems.Name && !productItems.Name.Contains("@"))))
                            {
                                chShared.Items.Add(productItems.Name);
                            }
                               
                            userEMAIL.Add(
                                new Dictionary<string, string>(){
                                {productItems .Name, productItems .Manufactory} });
    
                             
                        }
                    }    
            }


    • Edited by codek414 Wednesday, May 11, 2016 12:10 AM
    Wednesday, May 11, 2016 12:07 AM

Answers