vendredi 7 août 2015

How to bind data to DropDownList control from method in View

Can anyone help me How can i bind data into below DropDownList data is getting from a method GetItem in clArray class.Now I want get items into DropDownList control

`clArray aList = default(clArray);
long x = 0;
string sListItemText = null;
string sListItemValue = null;
                            //bind data to control
aList = oMLSList.GetList(goForm.Table, sField);
for (x = 1; x<=aList.GetDimension(); x++)
{
   sListItemText = aList.GetItem(x);
   sListItemValue = oMLSList.LReadSeek(goForm.Table + ":" + goTR.Replace(sField, "MLS_", ""), "VALUE", sListItemText);
   //oList.Items.Add(new ListItem(sListItemText, sListItemValue));
}
 <div class="form-group">
      <label for="inputEmail" class="@sLabelclass">@sLabel</label>
      @*<div class="@sCtrllass">*@
      @*<select id="@sField" class="form-control">
         <option value="@sListItemValue">@sListItemText</option>
         <option value="@sListItemValue">@sListItemValue</option>
         <option value="@sListItemValue">@sListItemValue</option>
        </select>*@
      @* <input type="text" class="form-control" id="@sField" placeholder="@sField">*@
      @* @Html.DropDownList("@sField", new List<SelectListItem>
         {
             new SelectListItem{Text= "@sListItemText", Value="@sListItemValue"}
         })*@

      @*</div>*@
  </div>`

Aucun commentaire:

Enregistrer un commentaire