0
我試圖在ASP.NET MVC應用程序中實現高級搜索與分頁功能。我試圖在QueryString中傳遞搜索過濾器參數。 但作爲搜索過濾器類型是有點複雜,它不正確地轉換如何將viewdata中的複雜類型轉換爲查詢字符串
幫助我實現這個/
這裏是我的行動
public ActionResult AdSearch(SearchFilter SearchTerm, int index = 0, int perPage = 1)
{
var customers = _repository.Search(SearchTerm, new SelectSpec(perPage, index * perPage));
ViewData["SearchTerm"] = SearchTerm;
return View("ExpertSearchResult", customers);
}
這裏是搜索過濾器
public class SearchFilter
{
public IList<string> Countries { get; set; }
public IList<string> Languages { get; set; }
public IList<string> Industries { get; set; }
public IList<string> Expertises { get; set; }
}
這裏是生成頁面鏈接的代碼
var searchCriteria = new RouteValueDictionary(ViewData["SearchTerm"]);searchCriteria.Add("perPage", 1);searchCriteria.Add("index", 1);return Html.ActionLink("First", "Results", searchCriteria)