Default value of Guid in GridColumn not working

If I set the default value like: 
DefaultValue="@(Guid.NewGuid().ToString())" or
DefaultValue="@Guid.NewGuid().ToString()"
in a column representing a Id the grid is refreshing itself constantly.

<GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" HeaderTextAlign="@TextAlign.Center" Width="140" DefaultValue="@(Guid.NewGuid().ToString())"></GridColumn>

3 Replies

RS Renjith Singh Rajendran Syncfusion Team March 23, 2020 04:34 AM UTC

Hi Fred, 

Thanks for contacting Syncfusion support. 

We suggest you to set the DefaultValue property for the GridColumn as like the below code to achieve this requirement. We have also prepared a sample for your convenience with our latest version 18.1.0.36, please download the sample from the link below, 

Please use the codes below, 

 
<GridColumn Field=@nameof(Book.OrderId) HeaderText="Order ID" IsPrimaryKey="true" ... DefaultValue="@Defaultguid"></GridColumn> 
 
@code{ 
    public string Defaultguid = Guid.NewGuid().ToString(); 
    ... 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 



FV Fred Vreenegoor March 23, 2020 07:56 AM UTC

ok thanks that works


RS Renjith Singh Rajendran Syncfusion Team March 24, 2020 04:29 AM UTC

Hi Fred, 

Thanks for your update. 

We are glad to hear that the provided solution helped you in achieving your requirement.  

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon