Link to home
Start Free TrialLog in
Avatar of Moti Mashiah
Moti MashiahFlag for Canada

asked on

C Shark

Hi guys ,

I'm trying to fill combobox with this code:

 void Fillcomb()
        {
            var db = new rmsmasterdbtestEntities1();
            comboBox2.DisplayMember = "";
            comboBox2.ValueMember = "SuplierName";
            comboBox2.DataSource = (from c in db.Suppliers
                                    select new { c.SupplierName}).ToList();
        }

Open in new window


And I'm getting this result - please see attachment.
what am I doing wrong?

Thanks ,
Capture.JPG
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Set the DisplayMember to SupplierName
Avatar of Moti Mashiah

ASKER

Now I did this:

void FillDept()
        {
            var db = new rmsmasterdbtestEntities1();
            combodept.DisplayMember = "supliername";
            combodept.ValueMember = "ID";
            combodept.DataSource = (from c in db.Suppliers
                                    select new { c.SupplierName }).ToList();
        }

Open in new window


And got this in the combobox - { SupplierName = A.I.RENTALS }
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ohh no , thank you very much and sorry about my stupidity :)..
thanks