Question C# .net windows programming..

nitish_07

Member
Joined
Feb 14, 2012
Messages
7
Programming Experience
Beginner
I have a datagridview through which i want to insert records in tables in database. But when i click on any row of gridview it shows this error

"Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function." at line datagridview.datasource=ds;

so how can i resolve it....plz help asap...:)
 
As the name suggests, this forum is for questions regarding VB.NET. There is a link at the top of the page to a sister forum for questions regarding C#. Please post all future questions regarding C# to that forum. I will answer this question here because it is not specific to either language but future questions that obviously relate to C# will be closed.

It sounds like you are handling the CurrentCellChanged or similar event of the grid and then executing some code that will cause the same event to be raised again. The system detects that this could cause an endless loop that would freeze the application and affect system performance so it terminates the operation right there. If you're setting the DataSource then that would obviously do it. Removing the current DataSource removes all the rows, so all the cells, so the current cell will no longer be the current cell, so the CurrentCellChanged event will be raised again. You need to rethink your logic. There's absolutely no way that making a selection in the grid should change the data in the grid.
 
Back
Top