I’m using Asp.Net with Razor syntax and latest Telerik components. Unfortunately when I click on dropdown box I see nothing in it but VS debugger shows me that I executed _AjaxLoaiding method. How can I solve this mystery (i.e. loading data into DropDownList)?
This is part of my Controller:
public ActionResult _AjaxLoading(string text) {
var product = new Dictionary<string, string>();
product.Add("a","b");
return new JsonResult { Data = new { Text = "Abc", Value = "123", Produtcs = new SelectList(product, "ProductID", "ProductName") } };
}
This is part of my View:
@{Html.Telerik().DropDownList()
.Name("documentType").Enable(false)
.HtmlAttributes(new { style = "width:250px;" })
.DataBinding(binding => binding.Ajax().Select("_AjaxLoading", "Applicants"))
.Render();
}
Hmm, your doing a strange thing : You pass a
Dictionary<string, string>to your select list, and asserts that the valueField is “ProductId”, and TextField is “ProductName”.Your dictionary has not such properties… Strongly typing is good.
So you would need a class Product (or whatever)
and use it, even for test purpose
EDIT :
By the way, if you want “Abc” and “123” in SelectList, this is not the right way to do, look at @Gaby’s answer in your previous post https://stackoverflow.com/a/10500876/961526
EDIT 2 :
let’s try again
so firt, some of my usual extension classes (I limited them, they used to be more generic, but… anyway)
then