Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a View and a Model corresponding to it.My problem is I want to populate drop downlist in the view using a different model in the same view.I seek your help
Posted

use Viewbag
as

SQL
public ActionResult PPEntry()
       {
           ViewBag.ddlData = new FillMaster().GetddList();
           //your model code
           return View(model);
       }


in your View

Select Block <select id="ddlMaster">
           @foreach (var item in ViewBag.ddlData)
           {
               <option value="@item.ID">@item.STATE</option>
           }
       </select>
 
Share this answer
 
As the Model is only a class.. You can use that class property inside you current Model which you are referring in the View and use that other model class property to assign the values in your drop down..
Hope this helps..!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900