drop down menu - C# DropDown List default value -



drop down menu - C# DropDown List default value -

i using code input values database table dropdown list:

<div class="editor-field"> @html.dropdownlistfor(model => model.tourimageid, new selectlist(model.images, "imageid", "filename", model.tourimageid)) </div>

what trying add together item top of list, not nowadays in database table.

something dropdown list values = (default-item) + (database-table-items)

is possible? if so, how?

if model.images of type selectlist, can in controller:

var query = unitofwork.globalimagelibraryrepository.images.select(x => new { x.imageid, x.filename }); viewmodel.images = new selectlist(query.asenumerable(), "imageid", "filename"); viewmodel.images.insert(0, new selectlistitem { value = "0", text = "--select--" });

i've assumed have method in globalimagelibraryrepository class returns iqueryable<images> this:

public iqueryable<images> images { { homecoming dbcontext.images; } }

so after that, view this:

<div class="editor-field"> @html.dropdownlistfor(model => model.tourimageid, (selectlist)model.images, model.tourimageid)) </div>

c# drop-down-menu

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -