Reputation: 1908
Basically my action return a viewModel with a List - each language has anID and a title
So in my view I have the following fropdown
@Html.DropDownList("Languages", new SelectList(Model.lstLanguages, "LanguageID", "Name"), "SELCT LANGUAGE----->",new { id = "ddlLanguages" })
SOmy question is - as I will have other views with dropdown and I will save in a session the id of the chosen language so when the user is redirected back by to this view
I want to be able to say something like this
ddllanguages.SelectedItem = @HttpContext.Current.Session["langID"]
Upvotes: 1
Views: 4569
Reputation: 1039588
@Html.DropDownList(
"Languages",
new SelectList(
Model.lstLanguages,
"LanguageID",
"Name",
Session["langID"]
),
"<-----SELECT LANGUAGE----->",
new { id = "ddlLanguages" }
)
Upvotes: 4