Solved

C# fill up combobox

Posted on 2014-04-30
2
898 Views
Last Modified: 2016-02-16
Hi Guys ,

I started a new project and I would like to work with the LINQ to ADO.NET Entity Data Model in order to query database from SQl server.

The application built base on widows form application and I would like to fill up some combobox with one of the column I have in the database.

Can somebody provide the code for this.

Also I need some code behind the data grid view to query couple of columns from different table.

Thanks ,
0
Comment
Question by:Moti Mashiah
2 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
Comment Utility
you can populate combobox like below. cmb1 is combobox object.

var db = new MyDataClass1DataContext();
cmb1.DisplayMember = "MY_TITLE";
cmb1.ValueMember = "MY_ID";
cmb1.DataSource = (from c in db.MY_MASTERs
                        select new { c.MY_ID, c.MY_TITLE }).ToList();

Open in new window

0
 
LVL 1

Author Closing Comment

by:Moti Mashiah
Comment Utility
Thank you very much I will open another thread for the second question " how to fill up grid from multiple tables.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now