c# - How to create Html.DropDownList or Html.DropDownListFor from a strongly typed model -


i have typed model.

@model ipacs.models.ipacs_departments 

this model has departmentid, name, description, owner.

i need populate dropdownlist model i'm not sure how?

i want value departmentid , text name.

here model using.

is model problem then?

public ipacs_departments() { this.ipacs_functions = new hashset(); this.ipacs_document = new hashset(); }

    [key]public int departmentid { get; set; }     public string name { get; set; }     public string description { get; set; }     public string owner { get; set; }      public virtual icollection<ipacs_functions> ipacs_functions { get; set; }     public virtual icollection<ipacs_document> ipacs_document { get; set; } 

i've tried syntax in answer below won't compile.

my model.departmentid, model.name, model.description, model.owner i'm not sure missing here.

there plenty of posts , documentation on this. here can you:

populating asp.net mvc dropdownlist

<%= html.dropdownlistfor(model => model.yourid, new selectlist(model.yourlist, "valuepath", "textpath"))%> 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -