This is a migrated thread and some comments may be shown as answers.

[Solved] optionlabel

1 Answer 120 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
nachid
Top achievements
Rank 1
nachid asked on 20 Sep 2010, 03:59 PM
Is there a way to pass optionlabel to Html.Telerik().DropDownList()

I' am trying to migrate this portion of code

<%: Html.DropDownListFor(x => x, new SelectList(MyColorList, @"Value", @"Text"), "Please select a color")%>

to

<%=Html.Telerik().DropDownList()
                           .BindTo(new SelectList(MyColorList, @"Value", @"Text"))

%>

but I cannot figure out how to pass the optionLabel "Please select a color"

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 21 Sep 2010, 09:02 AM
Hello nachid,

Unfortunately this functionality currently is not supported. Nevertheless you can vote for it in our PITS system.

As a workaround I can suggest you to add new SelectListItem with empty Value property and Text property set to the desired text:
<%
    var list = new SelectList(Model.Products, "ProductID", "ProductName").ToList();
    list.Insert(0, new SelectListItem { Text = "Select Value" });
%>
 
<%= Html.Telerik().DropDownList()
        .Name("DropDownList")
        .SelectedIndex(Model.DropDownListAttributes.SelectedIndex.Value)
        .BindTo(list)
        .HtmlAttributes(new { style = string.Format("width:{0}px", Model.DropDownListAttributes.Width) })
%>

Sincerely yours,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
nachid
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or