ViewDataDictionary can be used to replace the ViewData dictionary in the partial view... If you don't pass a ViewDataDictionary parameter then the parial's viewdata is the same as the parents.
@Html.Partial("_SomeTable", (List<CustomTable>)ViewBag.Table, new ViewDataDictionary {{ "Key", obj }});
passing data between partial views
how can i pass additional info in a call to a partial view?
im trying
from partial view A
Html.RenderPartial(partialviewB, widget, new ViewDataDictionary(this.ViewData) { { "NewRow", true } });
but nothing is in the ViewData when i try and access it this way in the called partial view (so a is always false)
in partial view B
var a = Convert.ToBoolean(ViewData["NewRow"]);
Hi Mark,
ViewDataDictionary can be used to replace the ViewData dictionary in the partial view... If you don't pass a ViewDataDictionary parameter then the parial's viewdata is the same as the parents.
http://www.codenoevil.com/pass-additional-viewdata-asp-net-mvc-4/
ok so is this the best approach for passing extra data to my partial view?
if so, how can i get it to work, the viewdata is empty in my called partial view when i try to access the key....
is working on a reply...