Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a datagridview which is populated from a datatable. This works fine. But if i exit the form where the datagrid and datatable run and try running it again i get an error Column name "id" already belongs to this datatable.

Ive tried everything to clear all the columns of the datatable and the datagridview but still the same

Thanks for any help
Posted
Comments
Richard C Bishop 8-Aug-13 13:37pm    
post the code
Thanks7872 9-Aug-13 0:17am    
Omg....Code project should provide us a facility to access OP's HDD.
Richard C Bishop 9-Aug-13 10:29am    
Yeah yeah, and remote viewing classes!
Kschuler 8-Aug-13 14:44pm    
Do you WANT the grid to reload when it comes back from the other form? If so, you could try setting the DataGridView's DataSource property = Nothing before reloading it.

Any other suggestions we could give really depend on your code. Please click the Improve question link and paste your code in the original question so that we can see what you are doing and better advise you.

Other relevant information would be helpful too, such as are ALL of your columns in the grid put there via data binding? Or do you have some columns pre-defined from design mode? And if so, what kind of column is the id column?

And when you say you've tried everything to clear the columns....well what have you tried? We need to know so that we don't suggest that method to you again.

1 solution

You need to re-initialize if any column you are trying to re-use.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900