Editform refresh

I'm trying to use editform in blazor as a replacement of the old FormView used in ASP.Net Webforms but I'm not able to find the right way to refresh the page and the data inside after updating the model.
Is it also correct to use editform as a replacement of the old FormView ?
To be more precise, I placed some buttons like "edit" "cancel" and "save" inside the editform to create te same functions available in the FormView of Asp.net webforms but supposing I changed the data using a c# code and I updated the database tables accordingly, how can I show the new data inside the editform ?
I don't have a editform.refresh() and if I use the same function used inside the "protected override void OnInitialized()" to load again the data, nothing happened inside the editform

5 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team September 22, 2020 12:25 PM UTC

Hi Walter, 



Greetings from Syncfusion support. 


You can refresh the editform by reinitializing the model value to default value using the below code. Refer to the below code, 



   public void refresh() 
    { 
        exampleModel = new ExampleModel(); 
    } 


Before refresh: 

 

After refresh: 

 
 
 
Please find the sample below, 
 
 
 
Kindly check the above suggestion and get back to us if  you need further assistance. 
 
 
Regards, 
Sevvandhi N 


Marked as answer

WM Walter Martin September 22, 2020 10:12 PM UTC

many thanks, it works in this way.

Just to be sure, is there any alternative to editform as a replacement of the old FormView used in the asp.net webforms ?
If I start from a datagrid everything is clear because I have automatically available the buttons to add delete and edit records, but what can I use to show the content of one only record in a new blazor page rather than editform to add delete or edit it ?




RN Rahul Narayanasamy Syncfusion Team September 24, 2020 03:32 PM UTC

Hi Walter, 

Thanks for the update. 

Query: what can I use to show the content of one only record in a new blazor page rather than editform to add delete or edit it ? 

We have validated your query and you want to add/edit the record in another page. Here, we have prepared a sample based on your requirement. We have rendered an EditForm in another page for Edit and Add operation. While clicking Add, Edit button in toolbar, it will navigate to Add, Edit page. You can perform your add, edit operation on that page. Find the below code snippets and sample for your reference. 

 
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit" })"> 
    <GridEvents RowSelected="RowSelectedHandler" OnToolbarClick="ToolClick" TValue="Order"></GridEvents> 
    <GridEditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true"></GridEditSettings> 
    <GridColumns> 
        . . . 
    </GridColumns> 
</SfGrid> 
 
@code{ public List<Order> Orders { get; set; } 
    public Order SelectedRecord { get; set; } = new Order(); 
    public void ToolClick(Syncfusion.Blazor.Navigations.ClickEventArgs Args) 
    { 
        if (Args.Item.Text == "Add") 
        { 
            NavigationManager.NavigateTo("addRecord/0"); 
        } 
        else if (Args.Item.Text == "Edit") 
        { 
            NavigationManager.NavigateTo($"editRecord/{SelectedRecord.OrderID}"); 
        } 
    } 
    public void RowSelectedHandler(RowSelectEventArgs<Order> Args) 
    { 
        SelectedRecord.OrderID = Args.Data.OrderID; 
    } 
    protected override void OnInitialized() 
    { 
        Orders = Ord.GetOrderDetails(); 
    }  
    } 


Please let us know if you have any concerns. 

Regards, 
Rahul 



WM Walter Martin September 24, 2020 05:58 PM UTC

Many thanks Rahul for this sample. It's exactly what I needed

Regards



RN Rahul Narayanasamy Syncfusion Team September 25, 2020 04:02 AM UTC

Hi Walter, 

Thanks for the update. 

We are happy to hear that the provided solution was helpful for your requirement. 

Please get back to us if you need further assistance. 

Regards, 
Rahul 


Loader.
Up arrow icon