开发者

Implementing refined search - ASP.NET MVC

In my ASP.NET MVC application I have a view that di开发者_JS百科splays a list of Products in the system. I would like to implement an option for users to filter the list of Products by selecting parametes, similar to the way it's done on www.codeplex.com. I would like to know how you would go about doing this in the most efficient and simple way? Any links to tutorials or guides are appreciated.


In our application we load up a list of all of the products into the web page, and use the Quicksearch jQuery plugin to filter the list. This allows the user to enter a word or two into a textbox, which collapses the list to only those entries matching what the user typed.


Basically, for a search of this type (server-side), you need:

  1. Fields in a <form> for the user to fill out to perform the search request.
  2. A button to post the form fields to your controller method
  3. A repository for the Linq queries that will return the proper records.
  4. A Method in the repository that accepts the parameters you have captured, and executes a linq query returning your filtered result, using Where clauses to filter the returned records.
  5. The result of the query gets returned to the view for display.

If you need dynamic capabilities (i.e. the user may omit one or more parameters, and you need the flexibility to specify those parameters in the Linq query at runtime), then have a look at Dynamic Linq.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜