Skip to content

Infragistics Community Forum / Web / Ignite UI for Blazor / How to call Web API or controller or c# code to save data to database

How to call Web API or controller or c# code to save data to database

New Discussion
Himanshu Upadhyay
Himanshu Upadhyay asked on Feb 14, 2022 3:04 PM

I am using Blazor server, and as Michael DiFilippo suggested, i am using CommitEditsAsync method to save data. But this method save/accept data in grid.

How we can call web API or controller or c# code to save data in database. I am using EditModeType.CellBatch, and on SAVE button, like to start a db transaction and save all changes. So that either all save or nothing save.

I was OnDataCommitting method is invoked when we call CommitEditsAsync. But this method give one row at a time. Therefore cannot control transaction.

Is there any way, when click SAVE button, then all changes pass to web api/controller or c# code, so that we can start database transaction and save changes. Appreciate if there is a sample project.

Sign In to post a reply

Replies

  • 0
    Michael DiFilippo
    Michael DiFilippo answered on Feb 14, 2022 2:26 PM

    Hello Himanshu, 

    Thank you for contacting Infragistics. This is a common question we get and because the grid does not talk directly to a database you'll require some adapter/api, as you pointed out, that connects your grid's datasource to the database. We don't have any solutions to provide as this will depend on your environment and falls outside of our area of support expertise. I suggest taking a look at this blog

    blazorhelpwebsite.com/…/34

    • 0
      Himanshu Upadhyay
      Himanshu Upadhyay answered on Feb 14, 2022 2:55 PM

      Thanks Michael for reply.

      I am not asking how to write API or c# to save data.

      My question is : 

      In Html.Infragistics, we have method .UpdateUrl(Url.Action("ControllerName")). And call our controller.

      In Blazor grid, i am not finding any property/method that i can point to my API or controller. As i said "CommitEditsAsync" not having parameter to point to API URL.

      Do i have to write OnDataCommitting and call API for each updated row? 

      • 0
        Michael DiFilippo
        Michael DiFilippo answered on Feb 14, 2022 3:04 PM

        Hello and thank you for following up. As mentioned in the previous update the datasource should be the one talking to your database and not the grid. You'll be cutting down performance if you try to hook one of our events. Instead you should keep track of when your collection is updated and perform the update. 

        see this discussion
        stackoverflow.com/…/cicular-database-update-on-collectionchanged-event

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Himanshu Upadhyay
Favorites
0
Replies
3
Created On
Feb 14, 2022
Last Post
4 years ago

Suggested Discussions

Created by

Created on

Feb 14, 2022 3:04 PM

Last activity on

Feb 11, 2026 9:48 AM