0

I have the following code

@Html.LabelFor(model => model.UserRole)
@Html.DropDownListFor(model => model.UserRole, new List<SelectListItem>
{
    new SelectListItem { Value = "Manager(SDD)" , Text = "Manager(SDD)" },
    new SelectListItem { Value = "Manager(QA)" , Text = "Manager(QA)" },
    new SelectListItem { Value = "Manager(Operations)" , Text = "Manager(Operations)" },
    new SelectListItem { Value = "Team Lead(SDD)" , Text = "Team Lead(SDD)" },
    new SelectListItem { Value = "Team Lead(QA)" , Text = "Team Lead(QA)" },
    new SelectListItem { Value = "Team Lead(Operations)" , Text = "Team Lead(Operations)" },
    new SelectListItem { Value = "Lead Developer(SDD)" , Text = "Lead Developer(SDD)" }
}, "Select one", new { @class = "form-control" })

Existing Role: ( @ViewBag.erole )`

Now i just want the DropDownlist's default list item to be the one returned from database, which is placed in ViewBag.erole.

Shariq Ali
  • 31
  • 1
  • 9
  • @StephenMuecke , I have a doubt, if some questions already have answer in SO , so should i direct the OP through comments or should i post answer to the question ? – Shaiju T Dec 08 '17 at 08:11
  • 1
    @stom, If you believe another post contains the answer, then vote (or flag) to close as a duplicate of it and it will go into the Close Votes queue for other to confirm (I have a gold badge so I closed this one without needing 5 votes) –  Dec 08 '17 at 08:15
  • I asked this question so that you can help me out, I've seen it but still it didn't help me. This is not really appreciable that how you guys just control what you want to. If you can help me with my code, my votes will be for you! – Shariq Ali Dec 08 '17 at 10:25

0 Answers0