Reputation: 1
I have model such as:
public class AdminArticleModel
{
public string Author
{
get;
set;
}
public string Title
{
get;
set;
}
public DateTime? SubmitedDate
{
get;
set;
}
public System.Data.Objects.DataClasses.EntityCollection<jpharmacareProject.ArticleFile> thearticleFiles
{
get;
set;
}
}
And In my action I am using code below:
[OutputCache(Duration = 0, VaryByParam = "None")]
public ActionResult Submitted()
{
string userID = User.Identity.Name;
List<AdminArticleModel> query = (from article in db.Articles
where article.User.userID == userID
&& article.IsTempArticle == false
select new AdminArticleModel() { Author = article.User.FirstName,
Title = article.Title,SubmitedDate=article.SubmissionDate,
thearticleFiles = article.ArticleFiles
})
.ToList<AdminArticleModel>();
ViewData["temps"] = query;
return View();
}
And I have created a strongly typed view to my model.but when i browse my action it is saying that the model is null.why it is not filled?how to fill it?
Upvotes: 0
Views: 120
Reputation: 7133
You have not specified your model. You have created a ViewData node.
To specify your model, change:
return View();
To:
return View(query);
See this article for more details about the Model and ViewData objects.
Upvotes: 2