John M
John M

Reputation: 14668

Filtering a Index view within ASP .NET MVC 3?

Is there a method to filtering a ASP .NET MVC 3 Index view?

I am thinking a search grid where you enter some parameters that then filter the indexs datasource. In PHP world I would use $_GET or $_POST to retrieve the search parameter results.

Upvotes: 2

Views: 1848

Answers (1)

Brian Cauthon
Brian Cauthon

Reputation: 5534

You can do the same in your index view. You just need to accept optional parameters in your controller.

public ActionResult Index(int? param1, string param2, int? param3){
    //filter away
}

I usually setup a form on the view for the parameter entry, and then just change the METHOD to GET instead of POST.

Upvotes: 3

Related Questions