Display Data From The Database Into Dropdownlist In Asp.net Mvc3
I am trying to fetch field data from the database and display in dropdown list. I am not getting proper output. I get model class name in dropdown. Model name: SearchMDLNoModel us
Solution 1:
You are using the wrong constructor of the SelectList
where the second parameter is the
selectedValue
.
You probably need this constructor where you can specify the dataValueField
and the dataTextField
So you should write create your SelectList
like this:
ViewData["MDLno"] =
newSelectList(SearchMDLNoDL.getAllMDLno(), "Request_For_Id", "Request_For_Id");
Post a Comment for "Display Data From The Database Into Dropdownlist In Asp.net Mvc3"