Cannot bind DropDownList in kendo grid. it works fine if it's not inside the grid. I try to use
@(Html.Kendo().DropDownList()
.Name("RegionId")
.OptionLabel("[|[Select...]|]")
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("FindAll", "region")
.Data("filterRegion");
})
.ServerFiltering(true);
})
.HtmlAttributes(new { @required = "" })
.Enable(false)
.AutoBind(false)
.CascadeFrom("CountryId")
.ValuePrimitive(true).HtmlAttributes(new { @required = "" })
)
and its bind as a text box, not drop-down list. how to make it bind drop-down list? note: the values do not have a relation in a database I need to just columns and make it by code.
It is not as simple as you may think I am afraid. The entire implementation can be found in the documentation of Telerik .
In a few words you have to:
Create an editor template for this class
@(Html.Kendo().DropDownList() .Name("Employee") // The name of the widget should be the same as the name of the property. .DataValueField("EmployeeID") // The value of the dropdown is taken from the EmployeeID property. .DataTextField("EmployeeName") // The text of the items is taken from the EmployeeName property. .BindTo((System.Collections.IEnumerable)ViewData["employees"]) // A list of all employees which is populated in the controller. )
Decorate your property with [UIHint("ObjectEditor")]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.