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.