Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
I want to clear the DataGrid that I am using.

This is the code I am currently using:-
C#
DataGrid.DataSource = null;
DataGrid.Rows.Clear();


It only works the first time it is used, although it removes the header when the record is updated.

Please can someone suggest where I am going wrong.
Posted
Updated 6-Oct-11 1:19am
v2
Comments
Herman<T>.Instance 6-Oct-11 6:56am    
what is your exact problem? and please DO NOT SHOUT. Normal casing is preferred
Bala Selvanayagam 6-Oct-11 7:00am    
Please do not post your question in upper case!!! it sounds rude
Member 8164209 6-Oct-11 7:27am    
ok sir
Member 8164209 6-Oct-11 7:27am    
Please Sort out my problem
[no name] 6-Oct-11 7:32am    
Don't be rude. It isn't up to us to sort out your problem.

only use
C#
DataGrid.Rows.Clear();
 
Share this answer
 
You should use DataGridView control instead of DataGrid.
The DataGridView control replaces and adds functionality to the DataGrid control,
and your code works perfectly with it.
 
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