Column reordering in DataTable

  • Thread starter Thread starter Hanan Taiber via .NET 247
  • Start date Start date
H

Hanan Taiber via .NET 247

It sounds simple but I couldn't figure a way to do it.

All I want to do is re-order the columns on my DataTable. For example, I like to make the second column the last column, make the third the first, etc.

When trying to remove a column from the collection and then add it to back, the data inside it is lost.

Do you know any simple way to do this?
 
Hanan:

Normally the position of the Columns doesn't affect the logic so I'm
guessing this is just a UI Issue? If so, then just change the positions of
the field in the query.

I'm not 100% sure but AFAIK there's no way to move them around other than
removing and readding them. If you store the values somewhere and then
reload the values after you've deleted then recreated it, the rowstate will
be modified so that will yield results you don't want.

Can you change the query?
Hanan Taiber via .NET 247 said:
It sounds simple but I couldn't figure a way to do it.

All I want to do is re-order the columns on my DataTable. For example, I
like to make the second column the last column, make the third the first,
etc.
When trying to remove a column from the collection and then add it to
back, the data inside it is lost.
 

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