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. Image for the cookie policy date

Aggregate columns dynamic, it throw an exception

hi team

im using dropdown list and grid

When an item is selected from the drop-down list, the grid data source fill with data

this is good but

When we make aggregate columns dynamic,it throw an exception:

 System.ArgumentException: An item with the same key has already been added. Key: S9.Pressure.Value

Is there a way to check if the key exists in the collection?

Or Reset aggregate columns items?

 <GridAggregates>

                    <GridAggregate>

                        <GridAggregateColumns>

                                @if (Aggerate != null)

                                {

                                   foreach (var col in Aggerate.Columns)

                                    {

                                     var pressure = "S" + col.Key.ToString() + ".Pressure.Value";

                                     <GridAggregateColumn Field="@pressure" Type="AggregateType.Average">

                                    </GridAggregateColumn>

                                   }

                                }

                            }

                        </GridAggregateColumns>

                    </GridAggregate>

                </GridAggregates>




1 Reply

VN Vignesh Natarajan Syncfusion Team October 26, 2022 05:05 AM

Hi Ali,


Thanks for contacting Syncfusion support.


Query: “When we make aggregate columns dynamic,it throw an exception: System.ArgumentException: An item with the same key has already been added. Key: S9.Pressure.Value Is there a way to check if the key exists in the collection?


We understand your issue but we need some more details to validate the issue further at our end. So kindly share the following information to validate the reported issue further at our end.


  1. Share the entire Grid code example.
  2. Are you facing the issue while compiling or while enabling the aggregates dynamically?
  3. Share the video demonstration of the reported issue.
  4. If possible share a simple issue reproducible sample.


The above-requested details will be very helpful in validating the reported issue at our end and providing a solution as early as possible.


Regards,

Vignesh Natarajan


Loader.
Live Chat Icon For mobile
Up arrow icon