検索とページングでビューを取得しようとしていますが、検索は問題ありませんが、次のページのリンクをクリックしても何も表示されません
[HttpGet]
public ActionResult Browse()
{
return View();
}
[HttpPost]
public ActionResult Browse(FormCollection formContent ,int? page)
{
string cartype = !String.IsNullOrEmpty(formContent["Cartype"]) ? formContent "Cartype"] : "";
string SearchBox = !String.IsNullOrEmpty(formContent["searchbox"]) ? formContent["searchbox"] : "";
DateTime toDate = !String.IsNullOrEmpty(formContent["toDate"]) ? DateTime.Parse(formContent["toDate"]) : DateTime.MaxValue;
string Sort = formContent["sort"];
mvc4advertismentEntities2 db = new mvc4advertismentEntities2();
var result = AdvertFunObj.GetAdverts();
switch (Sort)
{
case "":
result = db.Mercedes.Where(m => m.CarType == cartype).ToList();
break;
case "price":
result = db.Mercedes.Where(m => m.CarType == cartype).OrderByDescending(m => m.Price).ToList();
break;
case "date":
result = db.Mercedes.Where(m => m.CarType == cartype).OrderByDescending(m => m.ExpirationDate).ToList();
break;
case "enginecapaity": result = db.Mercedes.Where(m => m.CarType == cartype).OrderByDescending(m => m.EngineCapacity).ToList();
break;
}
int pageSize = 6;
int pageNumber = (page ?? 1);
return View(result.ToPagedList(pageNumber, pageSize));
}
景色
<table class="advertbrowsediv " id="searcht" width="100%"><tr><td style="width: 42%"> فئة السياره :
<br />
<%: Html.DropDownList("Cartype", new SelectListItem [] {
new SelectListItem(){Text="مرسيدس",Value="مرسيدس", Selected=true},
new SelectListItem(){Text="ميتسوبيشي",Value="ميتسوبيشي"},
}) %>
</td>
<td >ترتيب حسب :
<br />
<%: Html.DropDownList("sort", new SelectListItem [] {
new SelectListItem(){Text="",Value="", Selected=true},
new SelectListItem(){Text="التاريخ",Value="date"},
new SelectListItem(){Text="السعر",Value="price"},
new SelectListItem(){Text="سعة المحرك",Value="enginecapaity"},
},
</td><td><br /><input style=" float:right" type="submit" value="بحث>
</table>