Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 14, 2008 12:45 PM by Tolik
Sep 13, 2008 09:06 PM|LINK
If i have an mvc view content page and i have some data displayed and i want to add more data to this same view page when another actionresult occurs, how do i do this? for instance i have a page with a few details, when a link is clicked i want to go fetch
more data and display it on this same view not another view....how do i do this? thanks
Sep 13, 2008 11:00 PM|LINK
If I understand you right, you have simply add additional nullable parameter for your action (for example name it "expand"). Or provide default value through Routers. Then in this action method check value of it. If it parameter provided, load necessary
data and put it into ViewData. In your page check ViewData for this values, if it not null, then render more data on your page. else just do nothing.
I've try to take about basic principle. Solution can be more elegance if you need.
I hope it helps :)
Sep 14, 2008 11:01 AM|LINK
thank you...it works :) but, just out of curiousity, what is the more elegant solution?
Sep 14, 2008 12:45 PM|LINK
May be not more elegance.. But I'll describe more detailed.
If I need something similar I'll create MVC Web User Control (ExtendedDetails.ascx). Then create ViewData class for corresponded Controller. Initialize it as I write earlier. In View Page call HtmlRenderPartial("ExtendedDetails", ViewData.Model.ExtendedInfo),
where ExtendedInfo is a Property of ViewData class for containing additional information. In ExtendedDetails.ascx just chech ViewData.Model for null and render if it provided. In another case you can write link for extended page or what are you need by logic
of your application.