I have this kendo dropdownlist to populate with json result.
The code for kendo dropdownlist is :
@(Html.Kendo().DropDownList()
.Name("DropDownListMessageTemplates")
.DataTextField("TemplateValue")
.DataValueField("TemplateId")
.DataSource(datasource => datasource
.Read(read => read.Action("GetMessageTemplateJson", "Employee"))
.ServerFiltering(true)
)
.SelectedIndex(0)
)
The method to return json data is:
public JsonResult GetMessageTemplateJson()
{
var messageList = _context.MessageTemplate.ToList();
var json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(messageList);
return this.Json(json, JsonRequestBehavior.AllowGet);
}
Here the json result is returning values as :
[{"TemplateId":1,"TemplateValue":"Hi @Employee, would you like to come to office and talk about the recent job opportunity. Thanks"},{"TemplateId":2,"TemplateValue":"Hi @Employee, please come to office for hearing more about job suitable to you. Thanks"},{"TemplateId":3,"TemplateValue":"Hello @Employee, Greetings. I would like to talk to you about new opportunity here in @location. Please reply back. Thank you`"}]
But I am seeing undefined in the dropdownlist and if I go to each values in that, I can see [, {, etc type of values.
Can someone please help with this one to see each value instead of single characters.
Thank you
What I have tried:
[{"TemplateId":1,"TemplateValue":"Hi @Employee, would you like to come to office and talk about the recent job opportunity. Thanks"},{"TemplateId":2,"TemplateValue":"Hi @Employee, please come to office for hearing more about job suitable to you. Thanks"},{"TemplateId":3,"TemplateValue":"Hello @Employee, Greetings. I would like to talk to you about new opportunity here in @location. Please reply back. Thank you`"}]