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
Solved

C# fill up combobox

Posted on 2014-04-30
2
936 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET (2008) - Refactoring Question 2 24
InputLanguage 1 33
transaction in asp.net, sql server 6 43
Please explain purpose of GZIP 4 34
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

856 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