Yamini

Yamini

  • NA
  • 1
  • 1.4k

How to assign a model to a view from controller

Sep 11 2012 10:44 AM

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();