Answer the question
In order to leave comments, you need to log in
Autocomplete MVC fields?
There is a model:
public class Works
{
public int Id { get; set; }
public string name { get; set; }
public string laboriusness { get; set;}
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd'/'MM'/'yyyy}", ApplyFormatInEditMode = true)]
public DateTime completiondate { get; set; }
}
public class Employyes
{
public int Id { get; set;}
public string nameofemployye { get; set; }
}
public class Orders
{
public int Id { get; set; }
public int workid { get; set; }
public int employyeid { get; set; }
public string laboriusness { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd'/'MM'/'yyyy}", ApplyFormatInEditMode = true)]
public DateTime startdate { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd'/'MM'/'yyyy}", ApplyFormatInEditMode = true)]
public DateTime enddate { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd'/'MM'/'yyyy}", ApplyFormatInEditMode = true)]
public DateTime realenddate { get; set; }
}
Answer the question
In order to leave comments, you need to log in
We need to write an action filter that populates ViewData["employyeid"] with SelectListItem values from the database. Apply the action filter to the action where you want to make a dropdown list with these values. You need to insert @Html.DropDown("employyeid") into the view. The framework will do the rest.
P.S. For workid, the same thing, you can specify the required number of filters for the action.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question