c# - MVC Just populate viewbag once, between page default action result and httppost -
let's populate viewbag object in page action result this
public actionresult miemployeedetails() { var employees = _db.geo_employees.select(x => new selectlistitem { value = x.name, text = x.name }).tolist(); viewbag.employees = employees; return view(); }
and populate in view such
<%= html.dropdownlist("employees") %>
that's fine when hit submit button , goes httppost action result i.e.
[httppost] public actionresult miemployeedetails(formcollection fc) { return view(); }
i null reference exception on viewbag option. in httppost action result need reset viewbag object created in original page load action result ?
each request independent. need reinitialize view data if call view again post. exemption data sent client during post
Comments
Post a Comment