Solved

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

Posted on 2009-03-30
4
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
vamsankar earned 500 total points
ID: 24016796
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
ID: 24017000
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
ID: 24017326
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
ID: 24036740
Tried that, it does NOT remove the header. It removes the first row after the header.
Any other idea?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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