Question

I have two DropDownListFors. With changing the first one's selected item, the second one's list changes. There's no problem til here.

The problem is I want the second list to be empty before the first change of the first DropDownListFor. How can I do this?

In short, how can I have a DropDownListFor with no items at first?

Was it helpful?

Solution

I think I found it. It was so simple. :)

@Html.DropDownListFor( model => model.Student,
    new List<SelectListItem>() {
        new SelectListItem() { Text = "", Value = "" }
    })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top