[RESOLVED]how to save dropdown list value inside database in MVC


I have written code for creation of records manually in cshtml file

<div class="editor-label">
@Html.LabelFor(model => model.PartyCode)
<div class="editor-field">
@Html.EditorFor(model => model.PartyCode, new { style = "width:250px" })
@Html.ValidationMessageFor(model => model.PartyCode)

<div class="editor-field">
@Html.DropDownList("Mobiledropdown3", new List<SelectListItem>
new SelectListItem { Text = "HTC DESIRE", Value = "1"},
new SelectListItem { Text = "Moto G", Value = "2"},
new SelectListItem { Text = "GO mobiles", Value = "3"}
}, "Select Mobile")

I have table Mobilestore in sql server

MobileNo int

price int.

for example if i save in Mobilestore table
as MobileNo———1

while populating data from database,
‘HTC DESIRE’ should be displayed in the dropdownlist along with other values
Also while editing, inside dropdownlist ‘HTC DESIRE’ should be displayed along with other values in list.
Please help me to get solution



Hi rchandran.nr,

Thanks for your post.

You can use ViewBag.please refer to the following link:

#Populate Selected Item in DropDownList in Edit Mode MVC


More information:

#Binding Dropdownlist With Database In MVC


Hope this can be helpful.

Best Regards,


Leave a Reply