I have a dropdownlist that is populated from a database as:
PayrollDb pdb = new PayrollDb (); var addBranchGui = new branch(); addBranchGui.BranchTypes = new SelectList(pdb.branchtypes,"Id", "Type");
<p>Branch Type:@Html.DropDownListFor(x => x.BranchType, Model.BranchTypes, "Choose an option")</p>
This codes correctly populates the dropdownload list. Problem arises when user selects an option in the dropdownlist and submits the form and I catch the input data on
[HttpPost action method and insert it into a database table, it is the
"Id" field that gets inserted when I want the
"Type" field to be inserted.
I can understand that on Postback event, browsers is reading
"Id" field. Can someone please guide me how I can command the browser to give me the
"Type" field so I can insert that into database.