We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Example of CRUD operations with SQL server in ASP.NET Core Razor environment

Thread ID:

Created:

Updated:

Platform:

Replies:

146787 Aug 20,2019 08:39 AM UTC Dec 4,2019 06:19 AM UTC ASP.NET Core - EJ 2 4
loading
Tags: DataGrid
Albert Morgades
Asked On August 20, 2019 08:39 AM UTC

Hi,
I am using a dataGrid component in a ASP.NET Core Razor project to interact with a SQL database but cannot get the CRUD operations to work.
The routine defined in the removeURL property does not seem to be called at all.
Can you please tell me what is wrong with the code below? Thank you.

Index.cshtml
@page
...
@Html.AntiForgeryToken()

<ejs-grid id="GridPaikat"
          allowpaging="true"
          load="onLoad"
          toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete", "Search", "Cancel" })">
    <e-data-manager json="@Model.Havaintopaikka.ToArray()"
                    removeUrl="Remove"
                    adaptor="RemoteSaveAdaptor">
    </e-data-manager>
    <e-grid-editSettings allowDeleting="true"></e-grid-editSettings>
    <e-grid-columns>
        <e-grid-column field="Id" headerText="Id" width="50" isPrimaryKey="true"></e-grid-column>
        <e-grid-column field="Alue" headerText="Alue"></e-grid-column>
        <e-grid-column field="Lyhenne" headerText="Lyhenne"></e-grid-column>
        <e-grid-column field="Paikka" headerText="Paikka"></e-grid-column>
    </e-grid-columns>
</ejs-grid>

<script>
    function onLoad() {
        this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }];
    }
</script>

Index.cshtml.cs
...
        public JsonResult OnPostRemove([FromBody]CRUDModel<Havaintopaikka> value)
        {
            _context.Havaintopaikat.Remove(value.Value);
            return new JsonResult(value);
        }

Kevin Swanner
Replied On August 20, 2019 07:35 PM UTC

I have the same situation. I am trying to edit a DataTable retrieved from SQL Server using a DataGrid (any edit mode, but mostly either inline or form). I can get the data relatively simply. But after I edit, the routine called is wanting an IEnumerable and that's as far as I get. It would be nice to have a good example of how to do this, as the documentation doesn't go into much detail or explanation.

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On August 21, 2019 10:42 AM UTC

Hi Customers,  
 
We have prepared a sample with the CRUD Action in the Razor Page that can be downloaded from the following location.  
 
 
Regards,  
Seeni Sakthi Kumar S. 


Rui Mendes
Replied On December 3, 2019 08:35 AM UTC

Hi,

Disclaimer: new user here
´
Using the provided example https://www.syncfusion.com/downloads/support/forum/146787/ze/EJ2Grid334825853.zip  (which works well up-front) and updating to the newest EJ2.Asp:Net.Core versions 17.3.x breaks the solution with a "Uncaught SyntaxError: Unexpected token 'var'" error
 ],
  "dataSource": var DataManager=new ejs.data.DataManager({
  "adaptor": new ejs.data.RemoteSaveAdaptor(),
  "removeUrl": "/Index?handler=Remove",
  "json": ejs.data.DataUtil.parse.isJson([

I'm using EJ2 community license and am getting the same error: basically in my testings I find the Grid works well (e.g. fed from a list) until I start to adopt  <e-data-manager> tag (for CRUD implementation).

Any hints on what could be the cause?


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On December 4, 2019 06:19 AM UTC

Hi Rui, 
 
Query: newest EJ2.Asp:Net.Core versions 17.3.x breaks the solution with a "Uncaught SyntaxError: Unexpected token 'var'" error 
 
We can reproduce the reported problem and we have already fixed the reported problem at our end. You can resolve the reported problem by upgrading NuGet version to 17.3.0.31. For your reference, we have attached the sample with NuGet version 17.3.0.31. 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Seeni Sakthi Kumar S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon