Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 27th, 2007, 02:27 PM
Registered User
 
Join Date: Apr 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rearrange the column order in a datatable/dataset

hi,

i am using VS 2005. In my web application i populated datatable from a dataset. I removed somw unwanted columns using Datatable's Remove() method.

Now I wanted to arrange the order of the columns in my datatable. i.e. my col1 should be col1, col5 should be col2 and col2 should be col3,....so on. Please help me out for doing this.

Thanks in advance..
Kiran

 
Old April 27th, 2007, 02:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

how are you populating the colums of the grid?? in the IDE this is done by you moving the columns around.. if the columns are generated automatic then you maybe has to re arrange the sql in the order you want the colums (also don't select the ones that you don't want)...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
 
Old April 27th, 2007, 02:36 PM
Registered User
 
Join Date: Apr 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gonzalo,

thanks for the reply.

but the problem is I cannot make anychanges in my dataset because it is being used by someother part of the program too. whatever I do, I have to do it in the datatable or someother way after fetching the data from that dataset.

Is there a way for this?

Thanks in advance

 
Old April 27th, 2007, 02:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I insist.. since the problem looks like the way you show your data, why not arrange the control that show the data better than the datatable???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
 
Old April 27th, 2007, 02:49 PM
Registered User
 
Join Date: Apr 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again...

Actually i am exporting this data to a excel sheet and for a cleint download. so i need to export the data in arranged order...
 
Old July 3rd, 2007, 12:11 PM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found this:

"Sometimes the need may arise to have to re-arrange columns in a DataSet.
If you're using ADO.NET 2.0 then you can change the position of a column using the DataColumn.SetOrdinal() method.
MyDataSet.Tables["MyTable"].Columns["MyColumn"].SetOrdinal(5);"

here: http://www.levelextreme.net/ViewPage...507A6345413D3D
 
Old July 3rd, 2007, 12:12 PM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found this:
----------------------------------------------------------
Sometimes the need may arise to have to re-arrange columns in a DataSet.
If you're using ADO.NET 2.0 then you can change the position of a column using the DataColumn.SetOrdinal() method.
MyDataSet.Tables["MyTable"].Columns["MyColumn"].SetOrdinal(5);
-----------------------------------------------------------
here: http://www.levelextreme.net/ViewPage...507A6345413D3D





Similar Threads
Thread Thread Starter Forum Replies Last Post
Rearrange the column order in a datatable/dataset kiran_q8 ASP.NET 2.0 Professional 2 May 3rd, 2007 08:46 AM
Creating DataSet/DataTable from XML hhmoeller XML 4 March 22nd, 2006 10:41 AM
DataTable belongs to another DataSet bmains ADO.NET 2 December 20th, 2005 12:24 AM
For Loop problem with DataSet\DataTable musa BOOK: ASP.NET Website Programming Problem-Design-Solution 2 December 25th, 2003 03:11 AM
For Loop problem with DataSet\DataTable musa BOOK: Professional C#, 2nd and 3rd Editions 1 December 24th, 2003 09:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.