ASP.NET MVC - Pass Additional ViewData to a Strongly-Typed Partial View?

RenderPartial takes another parameter that is simply a ViewDataDictionary. You're almost there, just call it like this: Html. RenderPartial( "ProductImageForm", image, new ViewDataDictionary { { "index", index } } ) Note that this will override the default ViewData that all your other Views have by default.

If you are adding anything to ViewData, it will not be in this new dictionary that you're passing to your partial view.

RenderPartial takes another parameter that is simply a ViewDataDictionary. You're almost there, just call it like this: Html. RenderPartial( "ProductImageForm", image, new ViewDataDictionary { { "index", index } } ); Note that this will override the default ViewData that all your other Views have by default.

If you are adding anything to ViewData, it will not be in this new dictionary that you're passing to your partial view.

Exactly what I was looking for. Thanks! – Nathan Taylor Jul 23 '09 at 15:28 This really helped me too, thanks – qui Aug 25 '09 at 11:49.

Create another class which contains your strongly typed class. Add your new stuff to the class and return it in the view. Then in the view, ensure you inherit your new class and change the bits of code that will now be in error.

Namely the references to your fields. Hope this helps. If not then let me know and I'll post specific code.

The easiest way to pass additional data is to add the data to the existing ViewData for the view as @Joel Martinez notes. However, if you don't want to pollute your ViewData, RenderPartial has a method that takes three arguments as well as the two-argument version you show. The third argument is a ViewDataDictionary.

You can construct a separate ViewDataDictionary just for your partial containing just the extra data that you want to pass in.

Create another class which contains your strongly typed class. Add your new stuff to the class and return it in the view. Then in the view, ensure you inherit your new class and change the bits of code that will now be in error.

Namely the references to your fields. Hope this helps.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions