Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Importing data from dataview to datatable


Message #1 by smita <smita@j...> on Wed, 05 Mar 2003 13:11:32 +0530
Smita, I started to reply to your query a couple of hours ago, and then
stopped with the thought that maybe someone else would understand WHY 
you
were trying to do this, and help you do it.

Like Amit, my first thought is, "Create another view and sort it the way 
you
want it."  My second is, "Refresh the datatable with another trip to the
database, getting results from the db in the order required."

It is of course possible to programmatically create a datatable, set up 
its
columns and constraints, and then loop through a sorted dataview and
populate the new datatable with the sorted results.  But that would be
uglier than my dog.  Are you sure it's what you have to do?

HTH


-----Original Message-----
From: Amit Kohli [mailto:amit.kohli@d...]
Sent: Wednesday, March 05, 2003 9:55 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: Importing data from dataview to 
datatable


Smita,

As a starting point, in order to sort data you will first need to create 
a
dataview object from the dataset. I am assuming that you would like to
display the data in a grid. There are plenty of examples that will show 
you
how to do this, you'll just need to create the dataview as-

Dim dv as DataView
dv =3D DataSet.DefaultView (please check syntax and object hierarchy)

HTH

Amit

-----Original Message-----
From: smita [mailto:smita@j...]
Sent: Wednesday, March 05, 2003 1:42 AM
To: ASPX_Professional
Subject: [aspx_professional] Importing data from dataview to datatable



Hi All,

I want to create a datatable from a dataview. How do I achieve this??
Actually I have a datatable. I need the data in the datatable to be in
sorted order. That is the order should be sorted in Datatable itself not 
the
view. So i was thinking to store the sorted view into another datatable.
Please comment on what I am thinking is right or wrong. Or is there any
method to sort the original datatable itself?? I tried one more option 
of
using the select method of datatable to get the rows in sorted order and
store it in another datatable. But I could not sort on multiple columns. 
For
eg
sortedDataRows =3D DataTable.Select("field1> 0", "field1 DESC, field2 
ASC")


Thanks,
Smita







  Return to Index