How To Use Bind Attribute In Asp.Net MVC
In this article we will understand how to use Bind Attribute in Asp.Net MVC By Sagar Jaybhay . Also we will Understand Including And Excluding Properties In Model Binding. Bind Attribute In Asp.Net MVC In a previous article or aove we understand how to create IncludeList and Exclude List but there is another way to do the same functionality by using Bind class. Bind class has several overloaded methods by using this ou can Include and Exclude several properties from the strongly typed model. Below is the code for that. [HttpPost] // Bind Function public ActionResult Edit([Bind(Include = "EmpID,EmpGender,EmpSalary, EmpCity, EmpEmail, DepartmentID")]Employee employee) var emp = new BusinessLogic.Business().GetEmployee(employee.EmpID.ToString()); employee.EmpName = emp.EmpName; // UpdateModel(emp, new string[] "EmpSalary", "EmpGender", "EmpCity", "EmpEmail", "DepartmentID" ); if (ModelState.IsValid) new BusinessLogic.B