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.
Unfortunately, activation email could not send to your email. Please try again.

Column '[ColumnName]' Duplicates are not allowed

Thread ID:

Created:

Updated:

Platform:

Replies:

120183 Sep 8,2015 10:05 PM Sep 9,2015 07:30 AM Windows Forms 1
loading
Tags: GridGroupingControl
CHAIRAT YANWITTAYAKOOL
Asked On September 8, 2015 10:05 PM

I create a simple form for searching and grouping result. Like this: 

        public void InitializeData()
        {
            //Setup GridGroupingControl
            //Setup DataSource
            this.ggcStockResult.DataSource = _stockService.GetStockBalanceDataTable(_parameters);

            //Setup GroupArea
            this.ggcStockResult.ShowGroupDropArea = true;
             this.ggcStockResult.TableDescriptor.GroupedColumns.Add("ProductCode");
            this.ggcStockResult.TableDescriptor.GroupedColumns.Add("WarehouseCode");
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            InitializeData();
        }


When click search button, it shows results and group correctly. A problem occur when I click search again, it throw exception like this "Column 'ProductCode' Duplicates are not allowed"
Do you have any suggestion to resolve this?

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 9, 2015 07:30 AM

HI CHAIRAT,

On second clicking the Search button which will only reset the DataSource of the Grid, but the TableDescriptor objects are not disposed. Hence, it throws the “Duplicates are Not allowed” exception. To avoid the exception, clear the GroupedColumns collection before adding. Please refer to the below code example,

Code snippet :

        public void InitializeData()
        {
            //Setup GridGroupingControl
            //Setup DataSource
            this.ggcStockResult.DataSource = _stockService.GetStockBalanceDataTable(_parameters);

            //Setup GroupArea
            this.ggcStockResult.ShowGroupDropArea = true;

            //Clear the GroupedColumns
     this. ggcStockResult.TableDescriptor.GroupedColumns.Clear();
             this.ggcStockResult.TableDescriptor.GroupedColumns.Add("ProductCode");
            this.ggcStockResult.TableDescriptor.GroupedColumns.Add("WarehouseCode");
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            InitializeData();
        }

Regards,
Adhi.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;