This question is locked. New answers and comments are not allowed.
I have a grid for displaying Product details containing Name,Price and Category.
View-
<%= Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(keys => keys.Add(c => c.Id))
.ToolBar(commands => commands.Insert())
.DataBinding(dataBinding => dataBinding.Server()
.Select("Index", "Product")
.Insert("Insert", "Product")
.Update("Save", "Product")
.Delete("Delete", "Product"))
.Columns(columns =>
{
columns.Bound(c => c.Name);
columns.Bound(c => c.Price );
columns.Bound(c => c.Category.Name);
columns.Command(commands =>
{
commands.Edit();
commands.Delete();
}).Width(180).Title("Commands");
})
.Sortable()
.Scrollable()
.Pageable()
%>
In Controller-
[PopulateCategory]
public ActionResult Index()
{
return View(GetAllProducts());
}
I have written an attribute for populating Category :-
public class PopulateCategoryAttribute:ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.Controller.ViewData["Category"] =GetAllCategory();
}
}
And created a usercontrol DDLCategory.ascx
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Category>" %>
<%= Html.DropDownList(null, new SelectList((IEnumerable)ViewData["Category"], "Id", "Name"))%>
Now when I click on Edit Button I want Category column to be comboBox column. As shown in "http://demos.telerik.com/aspnet-mvc/Grid/DisplayAndEditTemplates/10248?Grid-mode=edit" How do I do this???
Currently when I click Edit Button Controller's Index method is called and then PopulateCategoryAttribute's OnResultExecuting method is called. This will populate Categories but to display comboBox in Category column how do I call the usercontrol.
View-
<%= Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(keys => keys.Add(c => c.Id))
.ToolBar(commands => commands.Insert())
.DataBinding(dataBinding => dataBinding.Server()
.Select("Index", "Product")
.Insert("Insert", "Product")
.Update("Save", "Product")
.Delete("Delete", "Product"))
.Columns(columns =>
{
columns.Bound(c => c.Name);
columns.Bound(c => c.Price );
columns.Bound(c => c.Category.Name);
columns.Command(commands =>
{
commands.Edit();
commands.Delete();
}).Width(180).Title("Commands");
})
.Sortable()
.Scrollable()
.Pageable()
%>
In Controller-
[PopulateCategory]
public ActionResult Index()
{
return View(GetAllProducts());
}
I have written an attribute for populating Category :-
public class PopulateCategoryAttribute:ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.Controller.ViewData["Category"] =GetAllCategory();
}
}
And created a usercontrol DDLCategory.ascx
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Category>" %>
<%= Html.DropDownList(null, new SelectList((IEnumerable)ViewData["Category"], "Id", "Name"))%>
Now when I click on Edit Button I want Category column to be comboBox column. As shown in "http://demos.telerik.com/aspnet-mvc/Grid/DisplayAndEditTemplates/10248?Grid-mode=edit" How do I do this???
Currently when I click Edit Button Controller's Index method is called and then PopulateCategoryAttribute's OnResultExecuting method is called. This will populate Categories but to display comboBox in Category column how do I call the usercontrol.