How to clear the property value from datagrid?

Hi, I have a datagrid with multiple selection, if i do some operations with 1 row selected, I check datagrid.value to get rows selected and finish correctly, inmmediately i select 2 rows more, and when i check Value property it returns 3 rows .

What do i need to do in datagrid to clear selected rows (property value) when the operation finishes? I try datagrid.Reload and datagrid.Reset and not working for clearing that collection.

Binding the grid to a list item is required

 IList<YourObject> selectedItems // Declare a List 
...
@bind-Value="@selectedItems"  // bind this to grid in razor page
...
selectedItems=null;                       //   Clears the grid selectedItems

I got the data through "Invoke data Source Method" in Load event and set a property. When I get the selected Items I do with "Selection = (List)this.datagrid0.Value;" for iterating elements.

When it finishes, next instruction is "this.datagrid0.Value = null", before it exits from event, i try again same operation and it passes again through "Selection = (List)this.datagrid0.Value;" and it returns as if row is still selected, as if datagrid never refresh that property. Indeed i try to Page Reload and visually datagrid changes correctly but Value property returns more items selected.

I missing something but I dont know what hehehe

You will need to set @bind-Value property as mentioned in my post so that you can Get/Set the Value property of the datagrid.
image
Please refer to multiple selection sample for more clarity.

Hi @Vinod_Pillai , I tried you explain and nothing changed, let see if i'm wrong

  1. I define a page property "seleccion" as a list of objects.
    image

  2. I indicate as ${seleccion} in a datagrid's property "Value"
    image

3.If i select rows, that variable "Seleccion" does not contains items. for trying to set null after getting the elements selected.

do you matter to put into a little video ?

Hi,
Your first step is correct.
In the second step you need to set the bind-Value property instead of Value as shown in my screenshot using Attributes so below tag is added to razor page

 @bind-Value="@Seleccion"

third step will work after above change
It is very simple it will work.