Search

Monday, March 2, 2015
0 comments

How to bind ComboBox using edmx in windows form c#

9:50 PMMonday, March 2, 2015

Introduction

In my previous article i have already explained about bind combo box with entity framework using code first approach. also bind combo box with ado.net. Now, today i am discussing about edmx file. Before bind the combo box with edmx file , first to add edmx file in the solution or you can say project. Now, add a combo box in the form.

Copy the following code and paste in class constructor after  InitializeComponent(); method.

 Student_DBEntities dc = new Student_DBEntities();
            var item = dc.Student_record;
            comboBox1.DataSource = item.ToList();
            comboBox1.DisplayMember = "Student_Name";

Now, Code generate the following output:

How to bind ComboBox using edmx in windows form c#

The following video cover all such types of things which is mentioned in the article, i am giving you this video for better understanding:

Here,
  1. Student_DBEntities is a context class through which we can access or manipulate database record. (Check the context file in your solution).
Context class in edmx folder
  1. Student_record is a public property through which we can communicate database table.
How to bind ComboBox using edmx in windows form c#
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top