Garima Bansal

Garima Bansal

  • 1.1k
  • 698
  • 41.7k

Using two model classes in one view MVC

Jun 7 2024 9:39 AM

i have class name MasterModel in which two different classes
1: MasterModel
2: departmentofficialsList

I want deptname from departmentofficialsList
in a view how can call departmentofficialsList class
but in a view MasterModel is using and i want Authority Name
in Model.DeptName

model PPAApplication.Models.ViewModel.MasterModel
{
    ViewBag.Title = "officermaster";
    Layout = "~/Views/Shared/_Citizenlayout.cshtml";
}

using (Html.BeginForm("officermaster", "Master", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div class="container">
        <center><h2>Officer Master</h2></center>
        <div class="panel-group">
            <div class="panel panel-primary">
                <div class="panel-heading">Add Officer</div>
                <div class="panel-body">
                    <div class="row form-group">
                        <div class="col-md-3 text-left">
                            <div class="editor-label">
                                <strong>Authority Name:<a class="text-danger"></a></strong>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="editor-field">
                                Model.DeptName
                              
                            </div>
                        </div>
}


Answers (2)