python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
kendo ui dropdownlist mvc

kendo ui dropdownlist

Hello everyone, i'm going to share the code sample for create Kendo UI DropDownList



Table of Constants

1. Kendo ui  Dropdownlist by using MVC API and jquery.

2. Kendo ui  Dropdownlist by using MVC 5 and MVC ViewBag

Kendo ui dropdownlist by using API and jquery



 public class TenantController : Controller
 {
        [Route("API/Tenant/GetTenants")]
        public IEnumerable<Tenant> GetTenants()
        {
            List<Tenant> objTenant = new List<Tenant>();
            try
            {
                objTenant = GetTenantFormDB().ToList();
                ViewBag.Tenant = objTenant;
            }
            catch (Exception ex) {
             //TODO: log error in db.
            }
            return objTenant;
        }

}

$("#ddlTenants").kendoDropDownList({
        optionLabel: "Please select a tenant...",
        dataTextField: "Name",
        dataValueField: "ID",
        dataSource: {
            type: "json",
            serverFiltering: true,
            transport: {
                read: "http://localhost:80/API/Tenant/GetTenants"
            }
        },
        change: function change(e) {
            //TODO : bindCompanyByTenantId(this._selectedValue);
        }
 });

The url (http://localhost:80/API/Tenant/GetTenants) call the API controller and return back the result and bind data source.

Kendo ui  dropdownlist by using MVC 5 and MVC ViewBag

@(Html.Kendo().DropDownList()
    .Name("ddlTenants")
    .HtmlAttributes(new { })
    .BindTo(ViewBag.Tenant)
    .DataTextField("Name")
    .DataValueField("ID")
    .OptionLabel("Please select a tenant...")


For more details you can visit below discussion links..


ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions