Samio

Samio

  • NA
  • 201
  • 176.7k

LINQ to Entities - how to get column value in a combobox selection

Mar 30 2012 2:09 PM
As displaying LastName in comboBox1, I need to display FirstName in TextBox1.

How can I do that in LINQ ?

My code is as follows

            using (LINQtoEntitiesEntities MyEntities = new LINQtoEntitiesEntities())
            {
                ObjectQuery<Employee> Emp = MyEntities.Employee;
                comboBox1.DataSource = (from u in Emp select new { u.ID, u.LastName, u.FirstName }).ToList();
                comboBox1.ValueMember = "ID";
                comboBox1.DisplayMember = "LastName";
             }



Answers (4)