I have a model that I’m using to pass data from my view to my controller but I have some unbound from textboxes and dropdownlists. How can I pass that unbound data from my view back to my controller using ViewData or ViewBag….or something. Thanks!
Share
Can you give an example? It looks as if you’re mixing up your terminology a bit. You don’t generally pass data from a view to a controller except via a
POST/GET. I’m going to assume that’s what you meant. You can get any data into your controller’s action method via a parameter with the same name or using aFormCollection.In your view it might have something like:
MVC will automatically take the value of
yourUnboundTextBoxNameand insert that value into the parameter of the same name. Or you can use theFormCollectionand get the value from there.FormCollection["yourUnboundTextBoxName"]