MVC3 I use in Form.cshtml
@Html.DropDownListFor(m => m.GroupID, ViewData["GroupNameDDL"] as SelectList, "-- Select one --") in ControllerViewData["GroupNameDDL"] = _tbl68SpeciesgroupsRepository.Tbl68Speciesgroups.Select(b => new {
Id = b.GroupID, Name = b.GroupName}); TELERIK MVC in EditorTemplate Tbl68SpeciesgroupsForeignKey.cshtml@using System.Collections @using Telerik.Web.Mvc.UI @(Html.Telerik().DropDownList() .Name("GroupNameDDL")in GridViewmodel.cs
.BindTo(new SelectList((IEnumerable)ViewData["GroupNameDDL"], "ID", "Name")))[Required] [UIHint("Tbl68SpeciesgroupsForeignKey")] public int? GroupId { get; set; }How to implementIn Telerik I use in Form.cshtmlcolumns.ForeignKey(b => b.GroupId, (IEnumerable)ViewData["GroupNameDDL"], "ID", "Name");"-- Select one --"
6 Answers, 1 is accepted
0
Carrie
Top achievements
Rank 1
answered on 26 Sep 2012, 11:26 PM
You can try .OptionLabel("-- select --")
0
Rudolf
Top achievements
Rank 1
answered on 27 Sep 2012, 01:27 PM
Sorry Carrie this dosn't work in Telerik MVC
columns.ForeignKey(b => b.GroupID, (IEnumerable)ViewData["GroupNameDDL"], "ID", "Name").OptionLabel("-- select --");
0
carlg
Top achievements
Rank 1
answered on 27 Sep 2012, 02:10 PM
In MVC, it's .Placeholder
0
Rudolf
Top achievements
Rank 1
answered on 30 Sep 2012, 01:12 PM
Hi carlg
I don't know how to implement Placeholder at my problem above?
I don't know how to implement Placeholder at my problem above?
0
Rudolf
Top achievements
Rank 1
answered on 30 Sep 2012, 01:13 PM
at Dec. 22.2011 Georgi Krustev wrote
OptionLabel functionality is in our ToDo list and is scheduled for the next service pack of the Telerik
I use Q2 2012 but it is not inside?
OptionLabel functionality is in our ToDo list and is scheduled for the next service pack of the Telerik
I use Q2 2012 but it is not inside?
0
Rudolf
Top achievements
Rank 1
answered on 03 Oct 2012, 10:44 AM
The solution is very simple
In Basic EditorTemplate GridForeignKey.cshtml
and nothing else
it works well
In Basic EditorTemplate GridForeignKey.cshtml
@using Telerik.Web.Mvc.UI @(Html.Telerik().DropDownList() .Name(ViewData.TemplateInfo.GetFullHtmlFieldName("")) .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"]) .Placeholder("-- Select one --") !!!!! )
and nothing else
columns.ForeignKey(b => b.GroupId, (IEnumerable)ViewData["GroupNameDDL"], "ID", "Name");
it works well