Click here to Skip to main content
15,918,243 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating the rows in datagridview at run time.And insert data into it according to
excuted query.
It works welll for first time after running the program.
So after executed query for second time i have to delete the previous rows.
So i am using there datagridview.Rows.Clear method but will throw an exception cannot
clear this.
So how to remove it..?
Or there is any other way to delete previous rows from datagridview..?
Posted
Comments
Thomas Krojer 25-Jan-11 4:43am    
Please add the exception to your question. And maybe a bit more of your code.
shakil0304003 25-Jan-11 4:52am    
Please give your exception?

1 solution

If you've bound the datagrid to a datasource, you can't just clear the rows.

You need to unbind (set to null) the datasource reference in the grid, or remove the rows from your datasource and rebind the grid
 
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