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

[Solved] Method not found

0 Answers 60 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.
Linh
Top achievements
Rank 1
Linh asked on 05 May 2012, 11:07 AM
I am experiencing problem with binding the grid. I have to precise this is my first time using MVC framework 2.0, telerik MVC controls (235) and .NET Framework 4.0. 

Unless I am wrong my views are strongly typed according the inherits value of the page declaration.

here is my first way 
controller:
public ActionResult GetCategoryList()
        {
            return View(CategoryProvider.GetCategories((string)Session["LANGUAGE"]));
        }
 
        [Telerik.Web.Mvc.GridAction]
        public ActionResult AjaxGetCategoryList()
        {
            return View(new Telerik.Web.Mvc.GridModel<CategoryViewModel>(CategoryProvider.GetCategories((string)Session["LANGUAGE"])));
        }
 
        [HttpPost]
        [Telerik.Web.Mvc.GridAction]
        public ActionResult InsertCategory()
        {
            CategoryViewModel c = new CategoryViewModel();
 
            if (TryUpdateModel(c))
            {
                c.CategoryId = Guid.NewGuid();
                CategoryProvider.Add(c);
            }
            return View(new Telerik.Web.Mvc.GridModel<CategoryViewModel>(CategoryProvider.GetCategories((string)Session["LANGUAGE"])));
        }
 
        [HttpPost]
        [Telerik.Web.Mvc.GridAction]
        public ActionResult UpdateCategory(string id)
        {
            CategoryViewModel c = new CategoryViewModel();
 
            if (!string.IsNullOrEmpty(id))
            {
                c.CategoryId = new Guid(id);
                if (TryUpdateModel(c))
                {
                    CategoryProvider.Update(c);
                }
            }
            return View(new Telerik.Web.Mvc.GridModel<CategoryViewModel>(CategoryProvider.GetCategories((string)Session["LANGUAGE"])));
        }
 
        [HttpPost]
        [Telerik.Web.Mvc.GridAction]
        public ActionResult DeleteCategory(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                CategoryProvider.Delete(id);
            }
            return View(new Telerik.Web.Mvc.GridModel<CategoryViewModel>(CategoryProvider.GetCategories((string)Session["LANGUAGE"])));
        }
view:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<HoaLinh.Models.CategoryViewModel>>" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Manager
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 
<%= Html.Telerik().Grid(Model).Name("Grid2")
    .DataKeys(dataKeys => dataKeys.Add(c => c.CategoryId))
    .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image))
    .DataBinding(dataBinding => dataBinding      
        .Ajax()
                .Select("AjaxGetCategoryList", "Admin")       
                .Insert("InsertCategory", "Admin")      
                .Update("UpdateCategory", "Admin")     
                .Delete("DeleteCategory", "Admin")
    )
    .Columns(columns => {
        columns.Bound(o => o.Name).Width(200);
        columns.Bound(o => o.Description);
        columns.Bound(o => o.Language).Width(90);
        columns.Command(commands => {
            commands.Delete().ButtonType(GridButtonType.Image);
            commands.Edit().ButtonType(GridButtonType.Image);
            commands.Custom("EditMenu").Ajax(false).Text("Menu").Action("GetMenuList", "Admin");
        });
         
    })%>
 
     
</asp:Content>


Doing this I get the following error: 

Server Error in '/' Application.
 
Method not found: 'System.Web.Mvc.MvcHtmlString System.Web.Mvc.Html.EditorExtensions.EditorFor(System.Web.Mvc.HtmlHelper`1<!!0>, System.Linq.Expressions.Expression`1<System.Func`2<!!0,!!1>>, System.Object)'.
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.MissingMethodException: Method not found: 'System.Web.Mvc.MvcHtmlString System.Web.Mvc.Html.EditorExtensions.EditorFor(System.Web.Mvc.HtmlHelper`1<!!0>, System.Linq.Expressions.Expression`1<System.Func`2<!!0,!!1>>, System.Object)'.
 
Source Error:
 
 
Line 9:  <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
Line 10:
Line 11: <%= Html.Telerik().Grid(Model).Name("Grid2")
Line 12:     .DataKeys(dataKeys => dataKeys.Add(c => c.CategoryId))
Line 13:     .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image))
 
Source File: d:\webspace\hoailinh-tool.com\httpdocs\Views\Admin\GetCategoryList.aspx    Line: 11
Stack Trace:
 
 
[MissingMethodException: Method not found: 'System.Web.Mvc.MvcHtmlString System.Web.Mvc.Html.EditorExtensions.EditorFor(System.Web.Mvc.HtmlHelper`1<!!0>, System.Linq.Expressions.Expression`1<System.Func`2<!!0,!!1>>, System.Object)'.]
   Telerik.Web.Mvc.UI.Html.GridEditorForCellBuilder`2.AppendEditorFor(HtmlHelper`1 htmlHelper, IHtmlNode container) in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridEditorForCellBuilder.cs:76
   Telerik.Web.Mvc.UI.Html.GridEditorForCellBuilder`2.AppendEditor(IHtmlNode container, HtmlHelper`1 htmlHelper) in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridEditorForCellBuilder.cs:64
   Telerik.Web.Mvc.UI.Html.GridEditorForCellBuilder`2.AppendCellContent(IHtmlNode td, Object dataItem) in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridEditorForCellBuilder.cs:51
   Telerik.Web.Mvc.UI.Html.GridDataCellBuilderBase.CreateCell(Object dataItem) in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridDataCellBuilderBase.cs:38
   Telerik.Web.Mvc.UI.<>c__DisplayClass41.<InitializeEditors>b__3d(GridColumnBase`1 column) in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Grid.cs:1447
   Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\Extensions\EnumerableExtensions.cs:61
   Telerik.Web.Mvc.UI.Grid`1.InitializeEditors() in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Grid.cs:1443
   Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Grid.cs:854
   Telerik.Web.Mvc.UI.ViewComponentBase.ToHtmlString() in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ViewComponentBase.cs:215
   Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToHtmlString() in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:154
   Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToString() in f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:159
   System.Web.HttpWriter.Write(Object obj) +27
   System.Web.Mvc.SwitchWriter.Write(Object value) +15
   System.Web.UI.HtmlTextWriter.Write(Object value) +37
   ASP.views_admin_getcategorylist_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer) in d:\webspace\hoailinh-tool.com\httpdocs\Views\Admin\GetCategoryList.aspx:11
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   ASP.views_shared_admin_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in d:\webspace\hoailinh-tool.com\httpdocs\Views\Shared\Admin.Master:35
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +55
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060
 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

If someone can point me what I may doing wrong, would be great. Thank you! 



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