2013-02-01 42 views
0

我有這樣的:ASP.NET MVC - Html.Action - 傳遞DateTime數據導致錯誤

@Html.Action("CheckForModifyPost", "Forums", new { postAuthor = item.Author.UserName, dateCreated = item.DateCreated}) 

,我得到以下錯誤在這:

模型項目傳遞到 字典爲空,但該字典需要類型爲「System.Int32」的非空模型項 。

兩個item.Author.UserNameitem.DateCreated不爲空,而我所知道的是,這已經是與item.DateCreated。我該如何解決這個錯誤?

+3

請分享您的其餘觀點。並解釋你是如何填充你的價值的 –

+1

你能否展示你正在調用的Action的簽名(參數名稱必須匹配)以及你的相關路由映射。 –

+0

只需在下面添加您的答案,並選擇它作爲正確的關閉此。 – Will

回答

0
suppose your controller is as follow 

ForumController.cs 
[httpGet] 
public void CheckForModifyPost(string postAuthor, DateTime dateCreated) 
{ 
    YOUR CODE GOES HERE 
} 



@Html.Action("CheckForModifyPost", "Forums", new { postAuthor = item.Author.UserName, dateCreated = item.DateCreated}) 



so in @html.Action pass the value with same name as in your action method like if in action method "postAuthor" as argument than in @html.Action pass the value of that argument with same name as in action method means use "postAuthor" in your @html.Action, 
if their is only one character different than error occure