Search code examples
c#asp.net-mvc-2asp.net-mvc-2-validation

MVC 2 - How to exclude multple columns in the create method


How can I exclude multiple columns when creating a new customer? The other column is the date that the record was created - called customer_dt.

public ActionResult Create([Bind(Exclude = "customer_id")] Customer customer)
{
    /* Do something here ... */
}

Solution

  • You may provide each field as a comma-separated list. For example:

     [Bind(Exclude="Customer_Id, Name,Description,Active")]