
I'm using the Kendo UI ASP.NET MVC Grid with a Custom Template which includes a DropDownList in a column. The data must be loaded based on different filters, so I populate the DropDownList via a DataSource.
Everything works fine, except if I do not change the value.
These are the steps:
* The grid is loaded, there is no option label, so the first entry is visible.
* If I change the value in the DropDownList, everything works fine and the value is sent to the Server
* If I do not change the value, I get null as value on the server.
It seems like the initial value is not sent back to the server.
What can I do about this? My Kendo Version is 2012.3.1114.
Greets
Attached my custom template in the grid:
@(Html.Kendo().DropDownListFor(m => m)
.Name("SalesRep")
.DataSource(
config => config.Read(read => read.Action("SalesRepRead", "TemplateData", new { area = "" }).Data("filterGrid")))
.DataValueField("Value")
.DataTextField("Text")
)
13 Answers, 1 is accepted
This behavior is expected if the value in the Grid is not matched in the items that are loaded. In order to avoid showing an item which value is not set to the model, you could use one of the following options:
- Use an OptionLabel.
- Bind a one time handler to the dropdownlist databound event and set the value in the model to be the same as in the dropdown.
- If the value is matched only for new items, you can also set a default value through the Grid DataSource Model.
Daniel
the Telerik team

Could you provide a runnable sample that demonstrates the issue? The default value was sent correctly without using option label at least when I tested the scenario on my side.
Regards,
Daniel
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

As far as I understood from your previous post, the problem was in case a default value that matches an item from the dropdownlist is set. If the problem is in the scenario a default value is not set then please check this issue for more detailed information about the problem.
Regards,
Daniel
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

1) MVVM is not being used.
2) The issue is, if the kendo dropdown is being used with the GridForeignKey column, regardless of the datasource, if no change event is fired for the dropdown, it will not send the value of the item showing in the dropdown to the controller. I don't think I can make it any more clear than that.
3) This happens even if the items DO MATCH.
4)The corrective action on the part of telerik is the make sure the value from the dropdown is populated to the viewmodel that is passed back to the controller, even if the change event for the dropdown is never fired.
The screenshots I sent clearly show the code to reproduce the issue with all default telerik templates.
The grid editor uses the MVVM bindings so the scenario is the same as the one discussed in the issue that I linked in my previous reply. If the value is not sent even if the value in the model is the same as the selected item value then I will again ask for a runnable sample so we can investigate further.
Regards,
Daniel
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

The value in the model is not the same as the selected item value with the code that you provided. The default value for the SelectedValue property is 0 and the value of the first item in the "TestList" is 1.
Regards,
Daniel
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.


I am not sure what else can I do to help with the the case when the value is different. As mentioned in my initial post, the behavior is currently expected and I have listed the possible approaches that can be used to avoid the problem. Also, as my colleague said in the linked issue the behavior is already considered to be changed.
Regards,
Daniel
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
