tags:

views:

18

answers:

3

In MVC, When the view initially loads, I do not get the error. Only after post back , it is giving "There is no ViewData item with the key ..."

+3  A: 

when you do a postback, you have to add the ViewData["key"] again in the method that lives under [HttpPost]

Stefanvds
A: 

Set a breakpoint at the first point in your View where you access ViewData. You should be able to set a breakpoint inside <% %>

Compare values on load and on postback, see which key is missing.

Make sure you add this key in the POST accepting method.

Kindness,

Dan

Daniel Elliott
A: 

On the method that receives the post, you need to send all the data to the view again.

This includes not only what you set in ViewData, but the (view) model if the view uses one.

eglasius