私はMVC3を使用して私たちのウェブサイトを再現しています。私は、いくつかの古いサイトの機能を再現するためのソリューションの周りに私の頭を包むことはできません。MVC3の個々のレコードをページする方法。アクセススタイル
私たちの現在のサイトは、パーセルを表示し、nextID、previousIDの2つのボタンを表示します。これらのボタンは、このように見える関数(ASP Classic)の呼び出しからurl文字列を返します。
Function GetNextID()
Dim Temp
SQLStmt.CommandText = "SELECT AccountNumber FROM " & DBOwner & "DataProperty Where cardnumber=1 and NBC <> 'TPMH' and LUC <> '6832' and closed = 0 and ParcelID > '" & PropertyID & "' order by ParcelID asc"
RSProp.Open SQLStmt
If Not RSProp.EOF Then
Temp = RSProp("AccountNumber")
Else
Temp = ""
End If
RSProp.Close
GetNextID = Temp
End Function 'GetNextID
これを行うより良い方法はありますか? MVC3で本来設計された詳細レベルでデータをページングする方法はありますか?
ViewResult Next(int parcelId)
{
return View("Show",_service.GetNextId(parcelId));
}
ViewResult Prev(int parcelId)
{
return View("Show", _service.GetPrevId(parcelId));
}
ViewResult Show(int parcelid)
{
var model = new Parcel();// replace Parcel with your model class here
// Here get all the Parcel properties from DB or from whereever.
...
return View(model);
}
P.S.:
私は何をしたくないことは
ViewResult Show(string parcelId)
{
if(Request["next"] == "next")
return _service.GetNextId(parcelId);
if(Request["prev"] == "prev")
return _service.GetPrevId(parcelId);
//Or return this parcel
return _service.getProperty(parcelId);
}