Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

85
Views
data comes to controller but not to view
 public ActionResult Index()
        {
         
        GetEmployee();

        return View();
    }

    private void GetEmployee()
    {
       
        SocialMedia item = new SocialMedia();
        var employee = _employeeRepository.GetById(Session.GetEmployeeNo());           
           //employee.No, employee.ManagerNo
            item.FirstName = employee.FirstName;
            item.LastName = employee.LastName;
            item.Departmen = employee.PositionCode;
        item.FullName = item.FirstName + " " + item.LastName;
        
    }

And my HTML

@using Models.Model

@model Models.Model.SocialMedia
                            <div>
                                @Html.LabelFor(model => model.FullName)
                            </div>
                            <div>
                                @Html.LabelFor(model=>model.Departmen)
                            </div>

And My result is

FullName Departmen

Name,surname and departmen were supposed to come but didn't. Can you help me

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I'd have expected something more like:

public ActionResult Index()
{
     
    var model = GetSocialMedia();

    return View(model);
}

private SocialMedia GetSocialMedia()
{
   
    SocialMedia item = new SocialMedia();
    var employee = _employeeRepository.GetById(Session.GetEmployeeNo());           
       //employee.No, employee.ManagerNo
        item.FirstName = employee.FirstName;
        item.LastName = employee.LastName;
        item.Departmen = employee.PositionCode;
    item.FullName = item.FirstName + " " + item.LastName;
    return item;
}

Data in a C# program doesn't appear in place B just because it was created in place A; it has to definitely be passed around so it ends up where it is expected to be

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!