HttpPostをキャッチしているとき、別のResultActionにリダイレクトしています。これは私のint値を保持していますが、リスト値は保持していません。理由がわからないようです。ページ番号=2、searchAction = 3、clearanceResults(リスト)の25項目の投稿を取得した場合。投稿に期待する内容が返されますが、Details ActionResultに到達すると、pageNumberとsearchActionのみが保持され、clearanceResultsのリストは保持されません。奇妙なことに、リストはnullではなく、カウントが0になっています。
モデル:
public class ClearanceListViewModel
{
public ClearanceListViewModel()
{
this.pageNumber = 1;
this.searchAction = 1;
this.lastPage = false;
}
public ClearanceListViewModel(int pageNumber, int searchAction)
{
this.pageNumber = pageNumber;
this.searchAction = searchAction;
}
public int pageNumber { get; set; }
public int searchAction { get; set; }
public List<ClearanceViewModel> clearanceResults { get; set; }
public bool lastPage { get; set; }
}
コントローラに投稿する:
[HttpPost]
public ActionResult Details(ClearanceListViewModel model, FormCollection collection)
{
ClearanceListViewModel cModel = new ClearanceListViewModel();
cModel = model;
cModel.clearanceResults = model.clearanceResults;
// do something
return RedirectToAction("Details", cModel);
}
コントローラでのアクション結果:
public ActionResult Details(ClearanceListViewModel model)
{
DataTable dt = new DataTable();
List<ClearanceViewModel> clearanceList = new List<ClearanceViewModel>();
//save any changes
if (model.clearanceResults != null)
{
ClearanceSave(model);
model.clearanceResults = null;
}
string inQuery = "select sku, qty from products";
// call the query
dt = AS400DAL.Instance.ExecuteQueryAsDataTable(inQuery);
model = Utility.Utility.ProcessClearanceSkus(dt, model);
return View("Index",model);
}
任意の入力をいただければ幸いです。
ありがとう!