Click here to Skip to main content
15,902,636 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi friends,
I have a create view in which employees will insert their names and annual salarys ? what i need is to show their employee names and their monthly salarys in index view ? Can anyone give me a sample code examples

for eg :

emp name is shiva and annual salary is 360000 is entered in create view

and i need to show in index view as shiva and 30000(monthly salary)
Posted
Updated 16-May-14 3:10am
v5
Comments
Maciej Los 16-May-14 12:35pm    
monthly salary = annual salary / 12
MurugappanCTS 16-May-14 13:33pm    
This Calculation i know sir, how to show this calculation in model or controller
[no name] 16-May-14 14:21pm    
You don't show anything in a model or controller, you show items in views. Improve your question, show us your code for what you have tried, and explain to us what the actual problem is.

1 solution

You can create new readonly property in Model for MonthlySalary as shown below and can access this property in View through Model. This readonly property calculates Monthly Salary automatically depending upon the value of AnnualSalary property.

C#
Public decimal MonthlySalary
{
    get {
      return AnnualSalary/12;
    }
}


I hope this will help you :)
 
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