Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I bind the Kendo Textbox control to its data?

I have designed a view using some of the Kendo Telerik controls. I am not sure how to bind their controls to data.

This generated scaffolded method works :

@Html.EditorFor(model => model.surName, new { htmlAttributes = new { @class = "form-control" } })

How do I bind the Kendo Textbox?

@(Html.Kendo().TextBox()
    .Name("fName") 
    .HtmlAttributes(new { placeholder = "First Name", required = "required", validationmessage="Enter First Name" })
)
like image 384
Andy Avatar asked Jun 17 '15 05:06

Andy


People also ask

How do you bind data in kendo grid?

Bind data to Kendo Grid by using AJAX Read action method. Change the datasource on change event of any HTML controls. Normally, a developer can bind the data to Grid by using AJAX Read method. This read method is ActionResult method in MVC which will return JSON DataSourceResult & direclty bind the data to Grid.

What is Kendo bind?

Binds a HTML View to a View-Model and initializes Kendo UI widgets from DOM elements based on data-role attributes, similar to kendo. init(). Model View ViewModel (MVVM) is a design pattern which helps developers separate the Model from the View.

How does Kendo grid read data?

Since you are using the data method, you should be able to access the data via the properties and methods of the resulting object. You should be able to check the length of gridData via console. log(gridData. length) , as well checking any individual object within the data via an array index console.


1 Answers

Use the Kendo().TextBoxFor method:

@(Html.Kendo().TextBoxFor(model => model.FirstName)
    .Name("fName")
    .HtmlAttributes(new { placeholder = "First Name", required = "required", validationmessage="Enter First Name" })
)
like image 127
Nic Avatar answered Sep 16 '22 15:09

Nic