changing Dataset column order

  • Thread starter Thread starter Bravo
  • Start date Start date
B

Bravo

Hi,

I am using a SP to fill a dataset and it has 5 columns
and data in it. I want to reorder the columns to

oldDs --> newDS
col1 --> col2
col2 --> col3
col3 --> col1
col4 --> col4

Anybody has idea of how to do this in best possible way?
A code snippet would be highly appreciated.

Thanks in advance
Bravo
 
Hi Bravo,

I don't know why you would do that.
You might construct your DataTable before filling it.
 
How about creating a DataView from the DataTable, then set DataView.Sort
property. Or create a new SP that sorts the way you actually need.

Brad Williams
 
I'm going to assume that changing the SP to publish the
columns in the right order is not a reasonable option.

Is there a reason why creating a view is not an option?
Loading the dataset from this instead?
 
My purpose for doing thnis is to format data in proper
sequence. I am using the dataset to read the values, but
then I have to reorder them in the sequence provided by
user and then format the data.

I hope I have clarified the matter.

Do you have any suggesion?

thanks
 
I have to develop a generic solution that would work for
any SP and any dataset based on config. file and hence I
can not opt for changing order in SP. Do you have any
idea of doing it ??

Thanks
Bravo
 
My goal is not to sort the data row, but to change the
order of columns ... any idea on how to do that??

I need to develop a generic solution which would work for
all SP, hence I can not opt for changing order in SP.

any idea?
 
Hi bravo,

Every UI datasink (what is the right term) such as DataGrid allows (or
should allow) you to reorder displayed columns.
 
Sorry, I answered question no one asked!

I think Miha gives the best solution for you. For example of how to do this
with Forms.DataGrid, search MSDN for:

Deleting Columns in the Windows Forms DataGrid Control

Brad Williams
 
Back
Top