I have a simple winform application with a GridDataBoundGrid control displaying data from Sql server from a stored procedure. This grid control needs to source data from multiple stored procedures. The result sets coming from these stored procs are very different sets of columns. Hence i need to re-initialize the databoundgrid everytime before populating the results using the standard datasouce/datatable binding. In fact, without resetting, it was giving me very unpredictable results when i was running different stored procedures. I searched your forums and found a mechanism to reset the grid. Here it is:
this.ResultsGrid.DataSource = null;
this.ResultsGrid.DataMember = "";
this.ResultsGrid.DataSource = new DataTable();
This is working however there is something not right with this. I have manually added a column to the grid that has a button to every row and associated a button click event. (code is below). When i press this button after going through a few refresh cycles on the grid, the button behaves strangely. it generates multiple click events on a single click. For example, if i have gone through two resets, it generates two clicks. 3 click events for 3 resets and so on!
So i think the reset/re-initialize of the DataboundGrid is not happening very cleanly. Some events or internal datastructures are still lingering around. Please help me fugure out the cleanest and fastest way to fully programmatically re-initialize the grid 100% (as if it was loaded for the very first time) with nothing internal lingering around from the prior data load.
BTW, i tried using dispose on the grid object and creating a new grid object but that did not work.
Here is the code i have to add a button column to the grid:
ARArulpriya Ramalingam Syncfusion Team January 6, 2020 07:00 AM
Thank you for using Syncfusion products.
We have validated the reported use case at our end by creating a simple sample. However, the GridCellButtonClick event triggers only once even after the binding source is changed. We suspect that the use case might be occurred due to some other grid settings or binding customization for GridDataBoundGrid. So, we request you to refer the below sample and let us know the customization that causes the issue at your end. That will be helpful for us to assist you further to provide you a better solution at the earliest.
Please get back to us with simple screenshot, if we misunderstood your requirement.
VIVishalJanuary 11, 2020 09:25 AM
Thank you for verifying. I am not sure why this happening for me however i have created a workaround for now by creating a simple bool variable to prevent adding (stacking) multiple event callbacks and ensure only one callback is registered. That worked for me.
ARArulpriya Ramalingam Syncfusion Team January 13, 2020 12:58 AM
Thank you for the update.
We are glad that the reported use case has been resolved at your end by invoking the event callbacks based on conditions. Please back to us, if you have any other queries.