forum

Home / DeveloperSection / Forums / Two model type in one View

Two model type in one View

Anonymous User177503-Nov-2014

I have a concern. I am populating a list from controller and showing a table. Now upon clicking of a button in table row, i want to populate modal popup for webform, which is a partial view. My problem is, when i am using List Type model, i am not able to convert that model from list to simple as i have to pass simple model to render webform. My code is as below:

Index.cshtml

@model List<MvcApplication3.Models.ModelList>
@foreach (var item in Model)
{
     @Html.Parial("PartialView")
}

ModelList.cs

publicclassModelList
{
     publicstring Name { set; get; }
     publicstring Product { set; get; }
     publicstring Status { set; get; }
     publicstring Password { set; get; }
     publicstring Email { set; get; }
 }

PartialView.cshtml

@model MvcApplication3.Models.ModelList
@using (Html.BeginForm())
{
   ////
}

Controller

List<ModelList> objList = newList<ModelList>();

return View(objList);

How can i be able to use same model in both ways.


Updated on 04-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By