Kendo UI Docs

Complete Kendo UI Documentation
Get Kendo UI
  • Home
  • API Reference
  • Getting Started
  • How Do I?
  • Tutorials
  • Demos

Getting Started

  • dataviz
    • chart
      • chart types
        • Area
        • Bar Chart
        • Bubble Charts
        • Line Chart
        • Pie Chart
        • Scatter Chart
        • Series Chart
      • Appearance
      • Data Binding
      • Overview
      • Tooltip
    • lineargauge
      • Overview
    • radialgauge
      • Overview
    • sparkline
      • Overview
    • stockchart
      • Overview
    • Appearance and styling
    • Performance tips
    • Supported Browsers
    • Troubleshooting
  • framework
    • datasource
      • Overview
    • draganddrop
      • Drag Component
      • Overview
    • globalization
      • Date Formatting
      • Date parsing
      • Define culture information
      • Number Formatting
      • Number parsing
      • Overview
    • hierarchicaldatasource
      • Overview
    • mvvm
      • bindings
        • Attr
        • Checked
        • Click
        • Custom
        • Disabled
        • Enabled
        • Events
        • Html
        • Invisible
        • Source
        • Style
        • Text
        • Value
        • Visible
      • ObservableObject
      • Overview
    • templates
      • Overview
      • Performance
    • validator
      • Overview
    • fx
      • Overview
    • spa
      • Layout
      • Overview
      • Router
      • View
  • mobile
    • ActionSheet
    • Application
    • Button
    • ButtonGroup
    • Forms
    • Icons
    • Layout
    • ListView
    • ModalView
    • MVVM Integration
    • NavBar
    • Pane
    • Performance
    • PopOver
    • Scroller
    • ScrollView
    • SplitView
    • Switch
    • TabStrip
    • Touch
    • View
  • using kendo with
    • aspnet mvc
      • helpers
        • autocomplete
          • Overview
        • calendar
          • Overview
        • chart
          • Ajax Binding
          • Overview
        • combobox
          • Overview
        • datepicker
          • Overview
        • datetimepicker
          • Overview
        • dropdownlist
          • Overview
        • grid
          • images
          • Overview
          • Ajax Binding
          • Ajax Editing
          • Batch Editing
          • Client Detail Template
          • Configuration
          • Custom Binding
          • Editor Templates
          • FAQ
          • Server Binding
          • Server Detail Template
          • Server Editing
          • Troubleshooting
        • lineargauge
          • Overview
        • listview
          • Binding
          • Configuration
          • Editing
          • Overview
        • menu
          • Overview
        • numerictextbox
          • Overview
        • panelbar
          • Overview
        • radialgauge
          • Overview
        • slider
          • Overview
        • splitter
          • Overview
        • colorpalette
          • Overview
        • tabstrip
          • Overview
        • colorpicker
          • Overview
        • timepicker
          • Overview
        • editor
          • Overview
        • treeview
          • Overview
        • flatcolorpicker
          • Overview
        • upload
          • Metadata
          • Modes
          • Overview
          • Troubleshooting
        • multiselect
          • Overview
        • window
          • Overview
        • stockchart
          • Ajax Binding
          • Overview
        • tooltip
          • Overview
      • migration
        • widgets
          • AutoComplete
          • Calendar
          • Chart
          • ComboBox
          • DatePicker
          • DateTimePicker
          • DropDownList
          • Grid
          • Menu
          • NumericTextBox
          • PanelBar
          • TabStrip
          • TimePicker
          • TreeView
        • Migrating to Kendo UI
      • vs integration
        • images
        • Configure Project Wizard
        • Convert Project Wizard
        • Introduction
        • Latest Version Retrieval
        • New Project Wizard
        • Upgrade Wizard
        • Visual Studio Extensions Options
      • images
      • Globalization
      • Introduction
      • Troubleshooting
      • VB Syntax
    • jsp
      • tags
        • autocomplete
          • Ajax Binding
          • Overview
        • calendar
          • Overview
        • chart
          • Ajax Binding
          • Overview
        • colorpalette
          • Overview
        • colorpicker
          • Overview
        • combobox
          • Ajax Binding
          • Overview
        • datepicker
          • Overview
        • datetimepicker
          • Overview
        • dropdownlist
          • Ajax Binding
          • Overview
        • editor
        • flatcolorpicker
        • grid
          • Ajax Binding
          • Ajax Editing
          • Batch Editing
          • Overview
        • listview
          • Ajax Binding
          • Editing
          • Overview
        • menu
          • Overview
        • multiselect
          • Ajax Binding
          • Overview
        • numerictextbox
          • Overview
        • panelbar
          • Overview
        • slider
          • Overview
        • splitter
          • Overview
        • stockchart
          • Ajax Binding
          • Overview
        • tabstrip
          • Overview
        • timepicker
          • Overview
        • tooltip
          • Overview
        • treeview
          • Overview
        • upload
          • Metadata
          • Modes
          • Overview
        • window
          • Overview
      • Introduction
    • php
      • widgets
        • autocomplete
          • Local binding
          • Overview
          • Remote binding
        • calendar
          • Overview
        • chart
          • Local binding
          • Overview
          • Remote binding
        • colorpalette
          • Overview
        • colorpicker
          • Overview
        • combobox
          • Local binding
          • Overview
          • Remote binding
        • datepicker
          • Overview
        • datetimepicker
          • Overview
        • dropdownlist
          • Local binding
          • Overview
          • Remote binding
        • editor
          • Overview
        • flatcolorpicker
          • Overview
        • grid
          • Editing
          • Local binding
          • Overview
          • Remote binding
        • listview
          • Editing
          • Local binding
          • Overview
          • Remote binding
        • menu
          • Overview
        • multiselect
          • Local binding
          • Overview
          • Remote binding
        • numerictextbox
          • Overview
        • panelbar
          • Overview
        • slider
          • Overview
        • sparkline
          • Local binding
          • Overview
          • Remote binding
        • splitter
          • Overview
        • tabstrip
          • Overview
        • timepicker
          • Overview
        • tooltip
          • Overview
        • treeview
          • Local binding
          • Overview
          • Remote binding
        • upload
          • Modes
          • Overview
        • window
          • Overview
      • Introduction
    • Using Kendo With Open Access ORM
    • Using Kendo With Rails
    • Using Kendo With RequireJS
  • web
    • autocomplete
      • Overview
    • calendar
      • Overview
    • combobox
      • Cascading ComboBoxes
      • Overview
    • datepicker
      • Overview
    • datetimepicker
      • Overview
    • dropdownlist
      • Cascading DropDownLists
      • Overview
    • editor
      • Image Browser
      • Overview
      • Troubleshooting
    • grid
      • Editing
      • Localization
      • Overview
      • Walkthrough
    • listview
      • Overview
    • menu
      • Overview
    • numerictextbox
      • Overview
    • panelbar
      • Overview
    • rangeslider
      • Overview
    • slider
      • Overview
    • splitter
      • Overview
    • tabstrip
      • Overview
    • timepicker
      • Overview
    • treeview
      • Overview
    • upload
      • Drag and drop
      • Metadata
      • Modes
      • Overview
      • Supported Browsers
      • Troubleshooting
    • window
      • Overview
    • colorpicker
      • Overview
    • multiselect
      • Overview
    • tooltip
      • Overview
    • Kendo Widget CSS Styles
    • RTL Support
  • Introduction
  • Changes and Backward Compatibility
  • Data Attribute Initialization
  • Javascript Dependencies
  • Kendo UI Mobile FAQ
  • Technical Requirements
  • ThemeBuilder
  • Troubleshooting
  • Widgets
Get Kendo UI
Home Getting Started using kendo with aspnet mvc helpers dropdownlist Overview

DropDownList

Edit this doc

The DropDownList HtmlHelper extension is a server-side wrapper for the Kendo UI DropDownList widget.

Getting Started

There are two ways to bind a Kendo DropDownList for ASP.NET MVC:

  • server - the data will be serialized to the client. No Ajax requests will be made.
  • ajax - the dropdownlist will make ajax request to get the data.

Configure the Kendo DropDownList for server binding

Here is how to configure the Kendo DropDownList for server binding to the Northwind Products table using Linq to SQL:

  1. Make sure you have followed all the steps from the Introduction help topic.

  2. Create a new action method and pass the Products table as the model:

    public ActionResult Index()
    {
        NorthwindDataContext northwind = new NorthwindDataContext();
    
    
    return View(northwind.Products);
    
    
    }
    
  3. Make your view strongly typed:

    • WebForms

      <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
         Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcApplication1.Models.Product>>" %>
      
    • Razor

      @model IEnumerable<MvcApplication1.Models.Product>
      
  4. Add a server bound dropdownlist:

    • WebForms

      <%: Html.Kendo().DropDownList()
          .Name("productDropDownList") //The name of the dropdownlist is mandatory. It specifies the "id" attribute of the widget.
          .DataTextField("ProductName") //Specifies which property of the Product to be used by the dropdownlist as a text.
          .DataValueField("ProductID") //Specifies which property of the Product to be used by the dropdownlist as a value.
          .BindTo(Model)   //Pass the list of Products to the dropdownlist.
          .SelectedIndex(10) //Select an item with index 10\. Note that the indexes are zero based.
      %>
      
    • Razor

      @(Html.Kendo().DropDownList()
        .Name("productDropDownList") //The name of the dropdownlist is mandatory. It specifies the "id" attribute of the widget.
        .DataTextField("ProductName") //Specifies which property of the Product to be used by the dropdownlist as a text.
        .DataValueField("ProductID") //Specifies which property of the Product to be used by the dropdownlist as a value.
        .BindTo(Model)   //Pass the list of Products to the dropdownlist.
        .SelectedIndex(10) //Select an item with index 10\. Note that the indexes are zero based.
      )
      

Configure the Kendo DropDownList for ajax binding

Here is how to configure the Kendo DropDownList for ajax binding to the Northwind Products table using Linq to SQL:

  1. Make sure you have followed all the steps from the Introduction help topic.

  2. Create an action method which renders the view:

    public ActionResult Index()
    {
        return View();
    }
    
  3. Create a new action method and pass the Products table as Json result:

    public JsonResult GetProducts()
    {
        NorthwindDataContext northwind = new NorthwindDataContext();
    
    
    return Json(northwind.Products, JsonRequestBehavior.AllowGet);
    
    
    }
    
  4. Add a ajax bound dropdownlist:

    • WebForms

      <%: Html.Kendo().DropDownList()
          .Name("productDropDownList") //The name of the dropdownlist is mandatory. It specifies the "id" attribute of the widget.
          .DataTextField("ProductName") //Specifies which property of the Product to be used by the dropdownlist as a text.
          .DataValueField("ProductID") //Specifies which property of the Product to be used by the dropdownlist as a value.
          .DataSource(source =>
          {
                 source.Read(read =>
                 {
                      read.Action("GetProducts", "Home"); //Set the Action and Controller name
                 })
                 .ServerFiltering(true); //If true the DataSource will not filter the data on the client.
          })
          .SelectedIndex(0) //Select first item.
      %>
      
    • Razor

      @(Html.Kendo().DropDownList()
          .Name("productDropDownList") //The name of the dropdownlist is mandatory. It specifies the "id" attribute of the widget.
          .DataTextField("ProductName") //Specifies which property of the Product to be used by the dropdownlist as a text.
          .DataValueField("ProductID") //Specifies which property of the Product to be used by the dropdownlist as a value.
          .DataSource(source =>
          {
                 source.Read(read =>
                 {
                      read.Action("GetProducts", "Home"); //Set the Action and Controller name
                 })
                 .ServerFiltering(true); //If true the DataSource will not filter the data on the client.
          })
          .SelectedIndex(0) //Select first item.
      )
      

Accessing an Existing DropDownList

You can reference an existing DropDownList instance via jQuery.data(). Once a reference has been established, you can use the API to control its behavior.

Accessing an existing DropDownList instance

//Put this after your Kendo DropDownList for ASP.NET MVC declaration
<script>
$(function() {
// Notice that the Name() of the dropdownlist is used to get its client-side instance
var dropdownlist = $("#productDropDownList").data("kendoDropDownList");
});
</script>

Handling Kendo UI DropDownList events

You can subscribe to all events exposed by Kendo UI DropDownList:

WebForms - subscribe by handler name

<%: Html.Kendo().DropDownList()
    .Name("dropdownlist")
    .BindTo(new string[] { "Item1", "Item2", "Item3" })
    .Events(e => e
        .Select("dropdownlist_select")
        .Change("dropdownlist_change")
    )
%>
<script>
function dropdownlist_select() {
    //Handle the select event
}

function dropdownlist_change() {
    //Handle the change event
}
</script>

Razor - subscribe by handler name

@(Html.Kendo().DropDownList()
  .Name("dropdownlist")
  .BindTo(new string[] { "Item1", "Item2", "Item3" })
  .Events(e => e
        .Select("dropdownlist_select")
        .Change("dropdownlist_change")
  )
)
<script>
function dropdownlist_select() {
    //Handle the select event
}

function dropdownlist_change() {
    //Handle the change event
}
</script>

Razor - subscribe by template delegate

@(Html.Kendo().DropDownList()
  .Name("dropdownlist")
  .BindTo(new string[] { "Item1", "Item2", "Item3" })
  .Events(e => e
      .Select(@<text>
        function() {
            //Handle the select event inline
        }
      </text>)
      .Change(@<text>
        function() {
            //Handle the change event inline
        }
        </text>)
  )
)

Page rendered at 5/19/2013 5:00:05 PM UTC.

Back to Top

Copyright © 2011-2013 Telerik Inc. All Rights Reserved