asp.net mvc 3 - List not being displayed in DropDown Menu at View -


i learning mvc. here's have tried far:

public class storexml {     public string storecode { get; set; }        public static iqueryable<storexml> getstores()     {         return new list<storexml>         {             new storexml { storecode = "0991"},             new storexml { storecode = "0015"},             new storexml { storecode = "0018"}         }.asqueryable();     } 

in controller:

public selectlist getstoreselectlist()     {            var store = storexml.getstores();         return new selectlist(store.toarray(),"storecode");     }      public actionresult indexddl()     {         viewbag.store = getstoreselectlist();         return view();     } 

in view:

@html.dropdownlist("store", viewbag.stores selectlist, "select store") 

what doing wrong here? dropdown shows cie_mvc.models.storexml no values. please suggest.

you're storing in viewbag.store , calling in view, viewbag.stores

public actionresult indexddl() {      viewbag.stores = getstoreselectlist();      return view(); }  @html.dropdownlist("store", viewbag.stores selectlist, "select store") 

as side note, issue using dynamic object. suggest putting property in viewmodel, intellisense.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -