Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

Datatable.Clear() method please help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cameljs18@yahoo.com - 11 Jan 2008 07:59 GMT
I have a datatable into which i insert data then display the data in a
datagridview.When i want to clear the table and place completely new
data in  the table, the table still retains the column headers(this is
using the datatable.Clear() method).The table then adds the new
headers to the old which results in empty columns.Please inform me how
to clear the data completely.thanks
QC - 11 Jan 2008 08:08 GMT
Datatable.Clear() methods clears only the data.

if you want to remove / clear all columns as well from it, use
DataTable.Columns.Clear() method.
Marc Gravell - 11 Jan 2008 08:13 GMT
> the table still retains the column headers
That is exactly as per the documentation (which only claims to remove
the rows):
http://msdn2.microsoft.com/en-us/library/system.data.datatable.clear.aspx

If you want to also clear the columns, then perhaps call
.Columns.Clear() - but to be honest, if you're doing that I'd be
tempted to simply throw the entire DataTable away and start with a new
one...

Marc
cameljs18@yahoo.com - 11 Jan 2008 09:37 GMT
On Jan 11, 9:59 am, camelj...@yahoo.com wrote:
> I have a datatable into which i insert data then display the data in a
> datagridview.When i want to clear the table and place completely new
> data in  the table, the table still retains the column headers(this is
> using the datatable.Clear() method).The table then adds the new
> headers to the old which results in empty columns.Please inform me how
> to clear the data completely.thanks

thanks works fine now

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.