c# - DropdownList Not Showing Selected Item -


i creating page edit non-conformance reports. page takes in model follows:

enter code here

on page, trying show dropdown list current value of faultcode property pre-selected. however, not working. instead have stripped basics , tried hard code pre-selected value, follows:

@{                 var faultcodelist = new list<selectlistitem>                 {                     new selectlistitem { text = "internal damage", value = "internal damage" },                     new selectlistitem { text = "customer problem", value = "customer problem"  },                     new selectlistitem { text = "incorrect material supplied", value = "incorrect material supplied"  },                     new selectlistitem { text = "received material damaged", value = "received material damaged"  },                     new selectlistitem { text = "no test certificate supplied", value = "no test certificate supplied" },                     new selectlistitem { text = "other", value = "other", selected = true}                 };             }              @html.dropdownlist("faultcode", faultcodelist) 

this still not work. however, if change name of field other faultcode - i.e faultcode2 - works fine!

why seeing strange behaviour? on same page have dropdown lists other fields, , working perfectly...

@html.dropdownlist("faultcode", new selectlist(faultcodelist, "value", "text","other")) 

you need bind selectlist list, last parameter can mention selected value "other".


Comments

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -