I have tried to create dropdown list with tag

        <select name="manufacturer" class="form-control">
            <option>@null</option>
            @foreach (var item in Model) {
                <option>@item.Manufacturer</option>
            }
        </select><br>

but here is a problem: It doesn't populate all available manufacturers and only shows items, from current page. Example: http://i.imgur.com/na0x5eQ.png

that's because it uses the model passed from controller which doesn't always contain every item from the database. (because of pagination or after search)

Here is full sidebar code in partial view

 @model IPagedList<Products>
@using PagedList
@using PagedList.Mvc

<div id="filter" class="left">
    @using (Html.BeginForm("Filter", "SearchFilter")) {
        <div>
            <b>Manufacturer:</b> <br>
            <select name="manufacturer" class="form-control">
                <option>@null</option>
                @foreach (var item in Model) {
                    <option>@item.Manufacturer</option>
                }
            </select><br>

            <b>Name:</b> <br>@Html.TextBox("name", null)<br>
            <b>Price From:</b> <br>@Html.TextBox("min", null)<br>
            <b>To:</b> <br>@Html.TextBox("max", null)<br>
            <button type="submit" value="search"><b>Search</b></button>
        </div>
    }
</div>

So what are the ways to fix this?

Related posts

Recent Viewed