Reputation: 1368
I have searched this thing but did'nt come to the conclusion that if I have 5-6 Dropdownlists in my page and I bind them with ViewData or ViewBag rather than using model as I find it a bit easy. Is there any performace relates issues?
Or is it that viewbag and viewdata will make the page heavy?
Please discuss.
Upvotes: 1
Views: 308
Reputation: 1038830
Is there any performace relates issues?
No.
Or is it that viewbag and viewdata will make the page heavy?
No.
Personally I never use ViewBag because this is a weakly typed collection. It makes my views having to bind from multiple data sources: model, viewbag, ... which IMHO is an anti-pattern. The only place the view should be consuming its data from is the view model. In the pure MVC pattern there's no such notion as ViewBag.
Of course that's just my personal point of view. You will see gazillions of blog posts and tutorials for ASP.NET MVC illustrating the use of ViewBag. So I guess it would really depend on your preference whether you would use it or not.
Upvotes: 5