Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Index page and filter

Tags:

asp.net-mvc

This seems like a very simple question, but I'm getting lost, and need a few pointers.

I am using ASP.NET MVC C#, and have an Index page which displays a list of items, which is working fine.

Now I'm trying to add a DropDownList that depending on what the user selects will filter the list of items. But I keep thinking how you would do this in ASP.NET Web with RunAt Server, which I know is wrong.

Any pointers would be welcomed.

like image 735
Coppermill Avatar asked Jun 22 '09 08:06

Coppermill


3 Answers

Put the select box in a form and make the form post back to a filter method in your controller. Or If you want to use ajax, use an Ajax.ActionLink to update the table with the filtered results

<% Ajax.ActionLink("Filter", "FilterMethod", null, new AjaxOptions { UpdateTargetId = "tableId" }, new { Title = "Filter results" }) %>
<table id="tableId"> .... </table>

Where "FilterMethod" is in yo0ur controller

like image 158
Jon Spokes Avatar answered Nov 16 '22 17:11

Jon Spokes


This might help.

like image 28
Galilyou Avatar answered Nov 16 '22 18:11

Galilyou


Also worth looking at:

http://jerrytech.blogspot.com/2009/06/implement-ajax-form-in-mvc-framework.html

like image 22
Coppermill Avatar answered Nov 16 '22 18:11

Coppermill