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

[Solved] Bug ? in DataBinding overloads for Select, Insert, Update, Delete

2 Answers 68 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.
Carl
Top achievements
Rank 1
Carl asked on 31 Mar 2011, 07:07 AM
I continue to encounter difficulties with DataBinding in the MVC Grid as demonstrated by the following error:

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1502: The best overloaded method match for 'Telerik.Web.Mvc.UI.Fluent.GridBindingSettingsBuilder.Insert(System.Web.Routing.RouteValueDictionary)' has some invalid arguments

Source Error:

Line 8:      .DataBinding(db => db.Ajax()
Line 9:          .Select("PdsDefault", new { controller = "GtgPds", action = "_NexusResourcesAjax" })
Line 10:         .Insert(new { controller = "GtgPds", action = "_NexusResourcesAjaxInsert" })
Line 11:         .Update(new { controller = "GtgPds", action = "_NexusResourcesAjaxUpdate" })
Line 12:         .Delete(new { controller = "GtgPds", action = "_NexusResourcesAjaxDelete" }))

Source File: d:\Inetdev\PortalDoorsSystem074Net40VS10\GTG.PDS.WebApps.AuthWriteMvcApp\Views\GtgPds\Nexus.cshtml    Line: 10 






Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225


In the above error report, note that the .Select() used an overload with the RouteName as first arg and it does work. But I am unable to get the simpler overload with just the RouteValueDictionary to work.

So the questions are: Bug ? Which of the overloads are supposed to work in which situations?
 

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 Mar 2011, 07:21 AM
Hi Carl,

The compilation error explains the problem quite well. There are two overloads of the Insert method which accept a single argument - the first needs a string whereas the second needs a RouteValueDictionary. You are trying to pass an anonymous object which is not supported. Here is the list of available overloads:

http://www.telerik.com/help/aspnet-mvc/overload_telerik_web_mvc_ui_fluent_gridbindingsettingsbuilder_insert.html

All the best,
Atanas Korchev
the Telerik team
0
Carl
Top achievements
Rank 1
answered on 01 Apr 2011, 06:08 AM
Thanks for link and help clarifying the overloads.

Since I have a ControllerBase inherited by various Controllers, I ended up also creating a ViewPageBase inherited by various Views with a property for the controller that made it much easier to call the correct controller with the desired action. Here's the excerpt for the ViewPageBase:

  public abstract class ViewPageBase : ViewPageBase<dynamic> { }
  // System.Web.Mvc.WebViewPage is for Razor views
  public abstract class ViewPageBase<TModel> : WebViewPage<TModel>
  {
    private string pdsController;
    protected string PdsController
    {
      get
      {
        if (string.IsNullOrEmpty(pdsController))
        { pdsController = Html.ViewContext.RouteData.Values["controller"].ToString(); }
        return pdsController;
      }
    }

 and then in the View with the Telerik MVC Grid, all I have to do to get the correct controller argument for the grid's Select/Insert/Update/Delete methods is use the custom property PdsController with the desired action. Though I probably should have named the property PdsControllerName because it's just the controller's name and not the actual controller.
Tags
Grid
Asked by
Carl
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Carl
Top achievements
Rank 1
Share this question
or