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

emplates can be used only with field access...

0 Answers 138 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.
Kevin
Top achievements
Rank 1
Kevin asked on 11 Apr 2011, 08:02 PM
EDIT: And of course I fat-fingered the title... /sigh I don't suppose an admin can correct it?

I've seen this question asked before, but I think my situation is a little different than the others.  The full exception I'm getting is: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.  Here is how to reproduce it...

Add a grid control to a page and place an Edit button in one of the columns.  Create an editor template in the ~/Views/Shared/EditorTemplates folder of the MVC project.  The template has to match the type of object that the grid displays.  So if the grid is showing a List<Customer> then the editor template should be named Customer.ascx.

At this point the code should compile and run without an trouble.  If I go back and try to add a Delete command alongside the Edit command, I get the exception mentioned earlier.  To me this is unintuitive as Delete doesn't really have an UI components apart from confirming the action.  I should note this is expected to be an AJAX deletion followed by an AJAX refresh of the grid.

So, in short - an AJAX grid with edit and delete commands, as well as a custom editor template view for the object type displayed in the grid results in the exception.  What am I missing?  There must be some magic under the covers that I'm not following.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Share this question
or