Reputation: 43
I am trying to restrict the options in the dropdownlist and I would like to do this at the view level. Thanks in advance!
<div class="toolbar">
<label class="category-label" for="category">Update By Service Tier: </label>
@(Html.Kendo().DropDownList()
.Name("AvailableServiceTiers")
.OptionLabel("Select")
.DataTextField("Name")
.DataValueField("ServiceTierId")
.AutoBind(false)
.Events(e => e.Change("changeSelectedServiceTier"))
.DataSource(ds =>
{
ds.Read("GetCustomerServiceTierNameList", "Descriptions", new {customerId = Model.OrganizationId });
})
)
<a id="SaveBatchServiceTestBtn" class="k-button k-button-icontext k-grid-save-changes" href="javascript:void(0)"><span class="k-icon k-update"></span> Save </a>
</div>
Upvotes: 0
Views: 54
Reputation: 1402
It is better to have your data populating separated from your view. In controller create something like:
ViewBag.AvailableServiceTiers= ds.Read("GetCustomerServiceTierNameList).Where();
Then in your view you can have:
@(Html.Kendo().DropDownList()
.Name("AvailableServiceTiers")
.OptionLabel("Select")
.DataTextField("Name")
.DataValueField("ServiceTierId")
.BindTo(AvailableServiceTiers)
Upvotes: 1