Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an Employee module and a Manager module.
In the employee registration page A drop down list is there where one can select a manager present in the database. So if u select the drop down list then that manager name should print in the text box.
My Module is
public partial class AttendanceEntities : DbContext
  {
      public AttendanceEntities()
          : base("name=AttendanceEntities")
      {
      }

      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          throw new UnintentionalCodeFirstException();
      }

      public virtual DbSet<Administrator> Administrators { get; set; }
      public virtual DbSet<Attendance_Code> Attendance_Code { get; set; }
      public virtual DbSet<Attendance_Log> Attendance_Log { get; set; }
      public virtual DbSet<Employee> Employees { get; set; }
      public virtual DbSet<Manager> Managers { get; set; }





my controller is

ViewBag.ManagerId = new SelectList(db.Managers, "ManagerId", "UserName", e.ManagerName);



my view is
<div class="col-md-10">
              @Html.DropDownList("ManagerId", "Select Manager")

          </div>


What I have tried:

I have tried some code but Manager Id is coming instead of Manager Name
Posted
Updated 27-Feb-17 19:25pm

1 solution

Google is your friend: mvc bind textbox to combobox selection - Google[^]

Found this in less than 10 seconds using the above search: c# - Fill textbox on dropdown selection in mvc entity framework - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900