[RESOLVED]Drop Down, formating of bootstrap not working with error

I have this drop down and when I apply the bootstrap it is not working. I need help. if I need to create some css and where to place it.

    <p>

        <div class="form-inline">
            Find by Last Name or First Name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as String, new { style = "width:200px", @class = "form-control" })

            Location:

            @Html.DropDownList("LocationList", "All", new { style = "width:200px", @class = "form-control" })


            <input type="submit" value="Search" class="btn btn-default" />
        </div>
    </p>

And I get this error….

CS1928: ‘System.Web.Mvc.HtmlHelper<PagedList.IPagedList<TweddlePhoneListApplication.Models.MasterList>>’ does not contain a definition for ‘DropDownList’ and the best extension method overload ‘System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper,
string, System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>, object)’ has some invalid arguments

         

try

@Html.DropDownListFor

in regards to other CSS, create a separate style sheet and write your own CSS in that.

Hi yguyon,

Thanks for your post.

According to your description,

yguyon

CS1928: ‘System.Web.Mvc.HtmlHelper<PagedList.IPagedList<TweddlePhoneListApplication.Models.MasterList>>’ does not contain a definition for ‘DropDownList’ and the best extension method overload ‘System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper,
string, System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>, object)’ has some invalid arguments

To add html attributes, You needed to do something like this:

@Html.DropDownList("LocationList", new List<SelectListItem>{
    new SelectListItem{ Text="value1",Value="1",Selected=true},
    new SelectListItem{Text=" value2",Value="2"},
   new SelectListItem{Text="value3",Value="3"}
}, "All", new { style="width:200px",@class="form-control"})
or

@Html.DropDownList("LocationList", (IEnumerable<SelectListItem>)ViewBag.LocationList, new { style="width:200px",@class="form-control" })


UPDATE:

A better way of doing this would be to use DropDownListFor

@Html.DropDownListFor(x => x.LocationListId, (IEnumerable<SelectListItem>)ViewBag.LocationListId, new {style="width:200px",@class="form-control" })

Hope this can be helpful.

Best Regards,

Eileen

<div class="controls">
 @Html.DropDownListFor(m => m.FTCustomerDetail.SelectedOrganization, new SelectList(Model.FTCustomerDetail.Oreganization.Organization, "Key", "Value", Model.FTCustomerDetail.SelectedOrganization), "---Select an Organization---", new { @name = "select2", @class = "select span6 textBoxh", @id = "orgSelection" })
                                           
                                        </div>

use this one

Leave a Reply