I was able to create a dropdownlist for my MVC project, but the value is not selected as selected value on the dropdownlist. It just shows whole county list from the first.The value is from database. I tried find it from previous post, but it was quite confusing. Please, suggest me for any idea.
Controller Code
public ActionResult Edit(int i)
{
var items = new SelectList(db.MST_COUNTRies.ToList(), "COUNTRY_ID", "COUNTRY_NM");
ViewData["MST_COUNTRies"] = items;
}
View Code
<p>
<%= Html.DropDownList("COUNTRY_ID", (SelectList)ViewData["MST_COUNTRies"])%>
</P>I was able to create a dropdownlist for my MVC project, but the value is not selected as selected value on the dropdownlist. It just shows whole county list from the first.The value is from database. I tried find it from previous post, but it was quite confusing. Please, suggest me for any idea.Controller Codepublic ActionResult Edit(int i){ var items = new SelectList(db.MST_COUNTRies.ToList(), "COUNTRY_ID", "COUNTRY_NM"); ViewData["MST_COUNTRies"] = items;}View Code<p> <%= Html.DropDownList("COUNTRY_ID", (SelectList)ViewData["MST_COUNTRies"])%></P>
View Complete Post