This is a migrated thread and some comments may be shown as answers.

[Solved] Get a selectedValue

0 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Won
Top achievements
Rank 1
Won asked on 09 Sep 2010, 07:29 PM
This is from http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-combobox-data-binding-client-side-binding.html.
It works well on my project for combobox.

My question is how I can assign "selectedvalue" when there is a value from database on the combobox.
Right now the combobox show values from the first what so ever.

Controller
public class HomeController : Controller
{
    //Used for the Ajax binding
    public ActionResult _AjaxBinding(string text)
    {
        var northwind = new NorthwindDataContext();
        // Return all products as JSON - {Text:'ProductName', Value:'ProductID'}
        return new JsonResult { Data = new SelectList(northwind.Products.ToList(), "ProductID", "ProductName") };
    }

    // Renders the view initially.
    public ActionResult Index()
    {
        return View()
    }
}

Tags
Grid
Asked by
Won
Top achievements
Rank 1
Share this question
or