Solved

How do I delete and set a new header in datatable?

Posted on 2009-03-30
4
243 Views
Last Modified: 2013-12-17
Hi,
Currently i have these info in my datatable:

col11     col12     col13     -> this is the header....i want to delete this header...
col21     col22     col23     -> and replace it with this (2nd row)
cell1       cell2     cell3
cell4       cell5     cell6

how do i delete the header (row1) and replace it and set it as header on my row2?

Please advise.
0
Comment
Question by:tangteng78
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
vamsankar earned 500 total points
Comment Utility
Hi,

check the following URL, you get solution for your problem.
http://www.aspnettutorials.com/tutorials/controls/data-table-csharp.aspx


thanks...
0
 

Author Comment

by:tangteng78
Comment Utility
Sorry, maybe i didn't put up the question clearly.
The data in the datatable is already prepopulated from an Excel file. Thus, i want to remove the header and replace it with the 2nd row (or any row from the datatable).
Thus, I don't think i can use the solution from the url.
Please advise.
0
 
LVL 13

Expert Comment

by:drypz
Comment Utility
Hi! Why don't you just remove the first row using RemoveAt() function. Something like this.

dt.Rows.RemoveAt(0); //dt as your datatable
0
 

Author Comment

by:tangteng78
Comment Utility
Tried that, it does NOT remove the header. It removes the first row after the header.
Any other idea?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now