我有這個模型狀態地獄 - Model.A如何同時成爲兩件不同的事情?
<%=Model.StartDate%>
<%=Html.Hidden("StartDate", Model.StartDate)%>
它輸出:
2010-05-11 11:00:00 +01:00
<input type="hidden" value="2010-03-17 11:00:00 +01:00" name="StartDate" id="StartDate">
什麼...
這是一個分頁機制,使隱藏的價值是在第一頁上有效,我已經能夠前進到下一頁。但是由於這些值不會正確更新,所以在那裏結束。
我需要做什麼?
使用firefox。
更新 - 更多的代碼
using (Html.BeginForm("Program", "Activities", null, FormMethod.Get, new { @name = "ProgramForm", id = "ProgramForm" }))
{
。
viewModel.StartDate = pagingService.StartDate;
return View(viewModel);
更新 - 完整的動作
[Authorize]
public ActionResult Program(string[] submit)
{
var viewModel = new ActivityProgramViewModel { UserID = LoggedInUser.UserID };
viewModel.Fresh = true;
TryUpdateModel(viewModel);
var pagingService = new OccurencePagingService(LoggedInUser.AllActivities.Where(a => a.StartTime != null));
if (!viewModel.Fresh)
{
pagingService.StartDate = ((DateTimeOffset)viewModel.StartDate);
pagingService.EndDate = ((DateTimeOffset)viewModel.EndDate);
}
if (submit != null)
if (submit.Contains("MoveBack"))
pagingService.MoveBack();
else if (submit.Contains("MoveForward"))
pagingService.MoveForward();
ViewData.Model = viewModel;
viewModel.Occurrences = pagingService.GetOccurences();
viewModel.Fresh = false;
viewModel.HasLess = pagingService.HasLess;
viewModel.HasMore = pagingService.HasMore;
viewModel.StartDate = pagingService.StartDate;
viewModel.EndDate = pagingService.EndDate;
return View();
}
什麼是核心日期:2010-05-11或2010-03-17? – 2010-04-08 11:36:07
前者..... – Martin 2010-04-08 11:57:38
請給我們展示一些更多的代碼:)你以某種方式發送StartDate。 pagingService.StartDate來自哪裏? – LukLed 2010-04-08 13:49:54