For temporary storage we use ViewData["name"] or TempData["name"]. In controller the values are stored in one of these temporary storages, and the views could read the values and finally typecasted to the html control's value type and then binded to the control.
Example:
Consider we need to pass value to an textbox.
in controller we give
ViewData["TextBox"] = "Textbox value";
in View we give :
< %= Html.TextBox("txtBox", ViewData["TextBox"].ToString())% >
In case of dropdowlist or listbox - need to typecast as (IEnumerable
No comments:
Post a Comment