insert a new column in DataTable at a specified position

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to insert a new column in DataTable at a specified position at
runtime.
Unfortunatly, the DataColumnCollection does not expose any method to do this
(like AddAt),Any ideas would be greatly appreciated?


Vinny
 
Is the source DataTable populated? And if so, with how many records? If it
is unpopulated or with a limited number of records, I would create a new
table and copy the existing records.

But there may be other options. What is the source of the original data?
If you're creating the table and/or filling it via a SQL query, can you
reorder the SELECT list to give you the data in the order you want with the
new column already there? You could even consider adding the new column by
way of your select statement such as

SELECT name, address1, NULL AS newColumn, city, state FROM SomeTable

There are probably many other ways to get to what you're trying to do, if
you'd give a little more information.

HTH

DalePres
MCAD, MCDBA, MCSE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top