I have a model which is normal a class just for a strongly typed view.
I am stuck.I want to show two model data in one View.one is simple and the other is coming from database (checkBoxList ) one.
Pls help.
What I have tried:
public class ProcessSelectDate
{
[Required]
public string fromdate { get; set; }
[Required]
public string Todate { get; set; }
}
and another model that is through Entity framework
public partial class Process
{
public decimal id { get; set; }
public string ProcessName { get; set; }
public bool Ischecked { get; set; }
}
I want to show the checkboxlist of processname in The view which is coming from database.
so my view will be
for textbox and checkboxList, moreover two models
@Html.TextBoxFor(model => model.FromDate)
</div> <br />
<div><span class="RequiredField">* </span>To Date:</div>
<div>
@Html.TextBoxFor(model => model.ToDate)
</div> <br />
@for (int i = 0; i < Model.processName.Count; i++)
{
@Html.HiddenFor(x => x.processName[i].Name)
@Html.CheckBoxFor(x => x.processName[i].Checked)
@Html.LabelFor(x => x.processName[i].Checked, Model.processName[i].Name)
}
and in controller
dbcontext db = new dbcontext();
db.Processes.ToList(); //