0
Reply

How to assign a model to a view from controller

Yamini

Yamini

Sep 11 2012 10:44 AM
1.1k

Hi,

I have to pass the model to a view dynamically. How can this be done. I have used ViewData for assigning the data in the controller. But I'm unable to get it i the view. If i write @model ViewData["DynamicModel"].ToString(); the page is not getting the hit to debug...here is the code snippet...


In the controller

==========

public

PartialViewResult CreateAuxiliary(string type, string packageSequence)

{

ViewData[

"DynamicModel"] = new List<AuxiliaryPackage>();

string pkgSequence = packageSequence;

ViewData[

"AuthorizationPackageSequence"] = packageSequence;

return PartialView("_CreateAuxiliary");

}


 



 

In the View

==========

@model VeiwData["DynamicModel"].ToString();