Hi,
I would like to fill the dropdownboxFor list items in the view from a string with values, stored in one field from the model. Hope this makes sense.
The model of the view
@model IList<SeaFuy.Models.tblArticleSpecDefinition>
I have a view
@using SeaFuy.Library @model IList<SeaFuy.Models.tblArticleSpecDefinition> @{ ViewBag.Title = "ManageFlexValues"; Layout = "~/Views/Shared/_Layout.cshtml"; }<main class="products"> @using (Html.BeginForm()) {<fieldset><ul id="tabs"><li><a href="#details" id="details-tab">Details</a></li></ul><div class="tabContent" id="details"><div class="col-max-width"><div class="data-group"> @for (var i = 0; i < Model.Count; i++) {<div class="display-none">@Html.EditorFor(x => x[i].SP_ID)</div> if (Model[i].SP_TYPE == "C") {<div class="list-left">@Html.DisplayFor(x => x[i].SP_DESCRIPTION)</div><div class="list-right"> @Html.DropDownListFor(x => x[i].SP_SV_VALUETOSTORE, new SelectList(new List<string>() { "ss", "bb" })) </div> } else {<div class="list-left"> @Html.DisplayFor(x => x[i].SP_DESCRIPTION)</div><div class="list-right">@Html.EditorFor(x => x[i].SP_SV_VALUETOSTORE) </div> } }</div></div></div></fieldset><div class="button-container flexbox"><input class="new" type="submit" value=@SeaFuy.ResourceProviders.LocalizationResourceProvider.Current.GetString("stAanmaken") /></div> }</main>
you see that the values of the dropdownlist are now "ss" and "bb". These values should be replace with the list of strings in the field
x[i].SP_VALUETYPE
So the Model of the view is a list of records, Depening on one field in a record it show a textbox or a dropdown. The values of this dropdown should come from another field in the same record.But somehow i cannot get this to work. I thought i make viewbags, but the problem is that this is a list. So i do not know how many records the user wil enter.
Any suggestions how to tackle this.
tnx. Marcel