How do I stop the values in a ViewBag being bound to controls in MVC? The view isn't strongly typed.
I am passing in a datatable to the View using a ViewBag. This datatable is passed as value to a custom control built using extension methods on HtmlHelper
.
The view has some logic which relies on the EntityID, so i pass EntityID to the view using a ViewBag.
The control builds, among other things, a hidden field with the name 'EntityID' and instead of using the value i am passing from my dataset to the html helper, it binds to the value in the ViewBag instead.
return htmlHelper.Hidden(name, value, attributes);
How do i get the HtmlHelper
to use my value instead of using what is in the ViewBag?
This happens when the view is rendered.
The call to the controller of the View is made via an Ajax GET request and the view html returned is appended to a div
.
The GET request sends an object to the action method. The object has a property named EntityID