Retain ViewData when editing variable length list
Posted
by
Pieter
on Stack Overflow
See other posts from Stack Overflow
or by Pieter
Published on 2011-01-14T15:33:37Z
Indexed on
2011/01/14
15:53 UTC
Read the original article
Hit count: 210
I'm editing variable length lists and use ViewData to pass around information for filling a DropDownList. I use the method described here for editing these lists: http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
The data for this dropdownlist comes from the database. As the ViewData is not available across requests, I currently do a new query to the database each and every time. This also happens when the ModelState is not valid and the form is redisplayed. Of course, this is less then ideal even for a light-weight query as this one.
How can I retain the information from that query across requests as long as the user is editing the page with that variable length list?
© Stack Overflow or respective owner