I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
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:
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,
- Student_DBEntities is a context class through which we can access or manipulate database record. (Check the context file in your solution).
- Student_record is a public property through which we can communicate database table.
Comments
Post a Comment