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

[Solved] placeholder in Html.Telerik().DropDownList()

3 Answers 113 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.
Dmitriy
Top achievements
Rank 2
Dmitriy asked on 21 Dec 2011, 07:20 PM
Good day
I have prepared html code and I need me in your Html.Telerik (). DropDownList () to put an empty 
<option value="0" selected="selected">Your Age</option>


that is, in the end should look like
<select name="">
<option value="0" selected="selected">Your Age</option>
<option value="13">13</option>
<option value="15">15</option>
</select>

tell me how to do this?

3 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 22 Dec 2011, 10:48 AM
Hello,

 
OptionLabel functionality is in our ToDo list and is scheduled for the next service pack of the Telerik Extensions for ASP.NET MVC. For you can achieve your goal with adding an item in the begging of the collection passed to the DropDownList.

Kind regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Dmitriy
Top achievements
Rank 2
answered on 22 Dec 2011, 02:11 PM
please tell me and then how to make the first record stood when the page loads? 
0
Accepted
Georgi Krustev
Telerik team
answered on 22 Dec 2011, 02:40 PM
Hello,

 
Check the following code snippet, which shows how to add an item at the begining of the collection and then bind the DropDownList:

<%
    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) })
%>

Regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
ComboBox
Asked by
Dmitriy
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Dmitriy
Top achievements
Rank 2
Share this question
or