- Home
- Forum
- ASP.NET MVC (Classic)
- Cannot Edit MVC grid using Entity Framework
Cannot Edit MVC grid using Entity Framework
Hi
I'm trying to update my MVC grid and it will not do it. I have looked are you examples but to no avail and have no hair left. :)
I am using VS2012. Entity Framework, .NET 4 with your Essenital Studio Version 10.4.0.71 components.
Once I double click or select the row and click onto the edit button in the toolbar it will not go into edit mode, but I have captured the request and response Fiddler Information is as follows -
Request:
GridRequestParams
| {"RequestType":9,"gridID":"CAREUserGrid","PrimaryKeys":["User_ID"],"PrimaryKeyValues":["5"],"GridSaveMapper":"/CAREUser/SaveMembership","GridEditMode":"Normal"} |
| ClientObject | {"AutoFormat":9,"AllowSorting":true,"AllowPaging":true,"AllowGrouping":false,"HttpRequestType":"post","ShowCaption":true,"ShowRowHeader":false,"VisibleColumns":[{"Name":"User_ID","Member":"User_ID","type":"Int32","HeaderText":"User ID","FormatText":"","JqueryFormat":"","Visible":true,"CssName":null,"Width":-1,"AllowFilter":true,"IsUnbound":false,"cellEditType":0,"numericEditParams":null,"percentEditParams":null,"maskEditParams":null,"TemplateColumn":false,"TemplateName":null,"AllowEditing":true,"ResizeSettings":true,"TextAlign":0,"AllowAutoWrap":true,"AllowSearching":true,"AllowContextMenu":true,"AllowFormatinEditMode":false,"HtmlEncode":false,"GridCommands":""},{"Name":"Account_Name","Member":"Account_Name","type":"String","HeaderText":"Account Name","FormatText":"","JqueryFormat":"","Visible":true,"CssName":null,"Width":-1,"AllowFilter":true,"IsUnbound":false,"cellEditType":0,"numericEditParams":null,"percentEditParams":null,"maskEditParams":null,"TemplateColumn":false,"TemplateName":null,"AllowEditing":true,"ResizeSettings":true,"TextAlign":0,"AllowAutoWrap":true,"AllowSearching":true,"AllowContextMenu":true,"AllowFormatinEditMode":false,"HtmlEncode":false,"GridCommands":""},{"Name":"Name","Member":"Name","type":"String","HeaderText":"Name","FormatText":"","JqueryFormat":"","Visible":true,"CssName":null,"Width":-1,"AllowFilter":true,"IsUnbound":false,"cellEditType":0,"numericEditParams":null,"percentEditParams":null,"maskEditParams":null,"TemplateColumn":false,"TemplateName":null,"AllowEditing":true,"ResizeSettings":true,"TextAlign":0,"AllowAutoWrap":true,"AllowSearching":true,"AllowContextMenu":true,"AllowFormatinEditMode":false,"HtmlEncode":false,"GridCommands":""},{"Name":"Mail_Address","Member":"Mail_Address","type":"String","HeaderText":"Mail Address","FormatText":"","JqueryFormat":"","Visible":true,"CssName":null,"Width":-1,"AllowFilter":true,"IsUnbound":false,"cellEditType":0,"numericEditParams":null,"percentEditParams":null,"maskEditParams":null,"TemplateColumn":false,"TemplateName":null,"AllowEditing":true,"ResizeSettings":true,"TextAlign":0,"AllowAutoWrap":true,"AllowSearching":true,"AllowContextMenu":true,"AllowFormatinEditMode":false,"HtmlEncode":false,"GridCommands":""},{"Name":"Description","Member":"Description","type":"String","HeaderText":"Description","FormatText":"","JqueryFormat":"","Visible":true,"CssName":null,"Width":-1,"AllowFilter":true,"IsUnbound":false,"cellEditType":0,"numericEditParams":null,"percentEditParams":null,"maskEditParams":null,"TemplateColumn":false,"TemplateName":null,"AllowEditing":true,"ResizeSettings":true,"TextAlign":0,"AllowAutoWrap":true,"AllowSearching":true,"AllowContextMenu":true,"AllowFormatinEditMode":false,"HtmlEncode":false,"GridCommands":""},{"Name":"Department","Member":"Department","type":"String","HeaderText":"Department","FormatText":"","JqueryFormat":"","Visible":true,"CssName":null,"Width":-1,"AllowFilter":true,"IsUnbound":false,"cellEditType":0,"numericEditParams":null,"percentEditParams":null,"maskEditParams":null,"TemplateColumn":false,"TemplateName":null,"AllowEditing":true,"ResizeSettings":true,"TextAlign":0,"AllowAutoWrap":true,"AllowSearching":true,"AllowContextMenu":true,"AllowFormatinEditMode":false,"HtmlEncode":false,"GridCommands":""},{"Name":"Location","Member":"Location","type":"String","HeaderText":"Location","FormatText":"","JqueryFormat":"","Visible":true,"CssName":null,"Width":-1,"AllowFilter":true,"IsUnbound":false,"cellEditType":0,"numericEditParams":null,"percentEditParams":null,"maskEditParams":null,"TemplateColumn":false,"TemplateName":null,"AllowEditing":true,"ResizeSettings":true,"TextAlign":0,"AllowAutoWrap":true,"AllowSearching":true,"AllowContextMenu":true,"AllowFormatinEditMode":false,"HtmlEncode":false,"GridCommands":""}],"PageSize":30,"CurrentIndex":0,"AllowDeleting":false,"GroupedColumns":[],"CaptionText":"{Caption} : {TotalRecordsCount} Items","Caption":"CARE Users","TotalRecordsCount":352,"EnableOnDemand":false,"AllowSummaries":false,"CurrentPageNo":1,"AllowFiltering":true,"AllowFormatFiltering":false,"AllowFormatGrouping":false,"SortColumn":[],"SortDirection":[],"FilterConditions":[],"AllowEditing":true,"ResizeSettings":{"ResizeToFit":true,"ClipContent":true},"AllowAutoWrap":false,"ShowStackedHeader":false,"StackedColumns":[],"MergeCells":[],"StackedRows":[],"AllowSearching":true,"SearchConditions":[],"ChildGrid":"","AllowNew":false,"AllowAlternateRowStyle":false,"Culture":"en-AU","FilterMode":"Default"} |
| RequestType | 9 |
| gridID | CAREUserGrid |
| EnableOnDemand | false |
Response Error Message:
"No generic method 'Where' on type 'System.Linq.Queryable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic."
What am I doing wrong?
Attached are my controller and view code.
Thanks
Paul
// MODEL
//=============================================================================
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
public partial class CAREUser
{
public CAREUser()
{
this.SSRS_Subscription_User = new HashSet<SSRS_Subscription_User>();
this.User_Hospital_Membership = new HashSet<User_Hospital_Membership>();
this.Metric_Sets = new HashSet<Metric_Set>();
this.VCubes = new HashSet<VCube>();
}
[DisplayName("User ID")]
public int User_ID { get; set; }
[DisplayName("Account Name")]
public string Account_Name { get; set; }
[DisplayName("Name")]
public string Name { get; set; }
[DisplayName("First Name")]
public string First_Name { get; set; }
[DisplayName("Surname")]
public string Surname { get; set; }
[DisplayName("Mail Address")]
public string Mail_Address { get; set; }
[DisplayName("Deprovisioned")]
public bool Deprovisioned { get; set; }
[DisplayName("AD User")]
public string AD_User { get; set; }
[DisplayName("SID")]
public string SID { get; set; }
[DisplayName("Description")]
public string Description { get; set; }
[DisplayName("Department")]
public string Department { get; set; }
[DisplayName("Location")]
public string Location { get; set; }
[DisplayName("Exclude From Stats")]
public bool Exclude_From_Stats { get; set; }
[DisplayName("Hospital Access Level")]
public byte Hospital_Access_Level { get; set; }
public virtual ICollection<SSRS_Subscription_User> SSRS_Subscription_User { get; set; }
public virtual ICollection<User_Hospital_Membership> User_Hospital_Membership { get; set; }
public virtual ICollection<Metric_Set> Metric_Sets { get; set; }
public virtual ICollection<VCube> VCubes { get; set; }
public virtual Hospital_Access_Levels Hospital_Access_Levels { get; set; }
}
}
//=============================================================================
// CONTROLLER
//=============================================================================
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CAREAdmin.Models;
using Syncfusion.Mvc.Grid;
using Syncfusion.XlsIO;
{
public class CAREUserController : Controller
{
CARE_ConfigEntities _db = new CARE_ConfigEntities();
// GET: /CAREUser/
{
var model = _db.CAREUsers.ToList();
return View(model);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(PagingParams args, int? User_ID)
{
var model = _db.CAREUsers.ToList();
return model.GridActions<CAREUser>();
}
public ActionResult SaveMembership(User_Hospital_Membership membership)
{
var user = _db.User_Hospital_Memberships.Find(membership.User_ID);
if (TryUpdateModel(user))
{
_db.SaveChanges();
}
var data = _db.User_Hospital_Memberships.Where(u => u.User_ID == membership.User_ID);
return data.GridActions<User_Hospital_Membership>();
}
}
}
//=============================================================================
// VIEW
//=============================================================================
@using CAREAdmin.Models
@model IEnumerable<CAREUser>
@(Html.Syncfusion().Grid<CAREUser>("CAREUserGrid")
.Datasource(Model)
.Caption("CARE Users")
.ShowCaption(true)
.EnablePaging()
.PageSettings(paging => paging.PageSize(30))
.EnableSorting()
.EnableFiltering()
.AllowSearching(true)
.AllowResizing(true)
.EnableRowHover(true)
.EnableContextMenu()
.ResizeSettings(resize => {
resize.ResizeToFit(true);
resize.ClipContent(true);
})
.ToolBar(toolbar =>
{
toolbar.EnableToolbar(true);
toolbar.Add(GridToolBarItems.Search);
toolbar.Add(GridToolBarItems.AddNew);
toolbar.Add(GridToolBarItems.Edit);
toolbar.Add(GridToolBarItems.Update);
toolbar.Add(GridToolBarItems.Delete);
toolbar.Add(GridToolBarItems.Cancel);
}
)
.Mappers(map =>
{
map.SaveAction("SaveMembership");
}
)
.Editing(edit =>
{
edit.AllowEdit(true);
edit.EditMode(GridEditMode.Normal);
edit.PrimaryKey(key => key.Add(item => item.User_ID));
})
.Column(column =>
{
column.Add(item => item.User_ID).HeaderText("User ID");
column.Add(item => item.Account_Name).HeaderText("Account Name");
column.Add(item => item.Name).HeaderText("Name");
column.Add(item => item.Mail_Address).HeaderText("Mail Address").CellEditType(CellEditType.StringEdit);
column.Add(item => item.Description).HeaderText("Description");
column.Add(item => item.Department).HeaderText("Department");
column.Add(item => item.Location).HeaderText("Location");
}
)
)
</div>
Thanks for using Syncfusion Products.
We suggest you to follow up the Direct Trac incident 103685 regarding this query.
Please let us know if know if you have any concerns.
Regards
Bala Murugan A.S
Hi
Thanks.
I have found the error in my ways of how to look at the interaction between the
Grid and Controller: I realise I have to create the repository classes to
handle the editing, etc..
Cheers
Paul
Thanks for your update.
Please get back to us if you have any other concerns or queries.
Regards,
Bala Murugan A.S
- 4 Replies
- 2 Participants
-
PJ paul jilek
- Jan 23, 2013 06:21 AM UTC
- Feb 1, 2013 04:37 AM UTC