Get many filter parameters
I have a grid in which, I load data from database. I need to create filter on each column in the grid. It's about 12 columns and I don't want pass all my filter parameters through my function.
public ActionResult Index(int? StationCategory, int? StationPosCountry,
GridSortOptions gridSortOptions, int? page, int? pageSize .........)
{
}
I also view that parameters can be read in this way:
var request = Request.QueryString.ToRouteDic();
request would contain, two collec开发者_运维技巧tions Keys and Values, it more comfotable for me, but may be this keep hidden danger. My question is in witch way, it's better pass many filter parameters?
You can put all those parameters into a class
public class GridParameters
{
public int? StationCategory {get;set;} ...
}
then use that object as input and mvc should simply bind them to the properties with the same name
public ActionResult Index (GridParameters formModel)
精彩评论