Solved

C# fill up combobox

Posted on 2014-04-30
2
964 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 40033921
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
ID: 40034588
Thank you very much I will open another thread for the second question " how to fill up grid from multiple tables.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change to file doesn't show up 16 93
array not updating 8 42
Send parameters via datatable ajax call 4 48
VS C# how to design libary of functions 7 33
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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