DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Posts
    11

    Question How to put data from an IList to a Dataset.

    Pls tell me how to put data from an IList to a Dataset.
    Regards.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Assuming the IList contains String data:
    Code:
    Dim dt As New DataTable
    Dim col As New DataColumn("ColumnName", GetType(String))
    dt.Columns.Add(col)
    For Each Item As Object In MyIList
        Dim row As DataRow = dataTable.NewRow()
        row("ColumnName") = Item
        dt.Rows.Add(row)
    Next
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Nov 2005
    Posts
    11

    Question

    Thanks with your help. I'm sorry that I didn't give u detail question & requirement.
    I used Oject.Net to get data from a database to an IList (function PersistenceManager.getAllObjectsFromDb(typeof(Student))

    public class Student
    {
    int m_StudentId;
    string m_Name;
    string m_Email;
    ....
    }

    When I run, it will return an IList containing an array of Student object. After that I bind this IList to a datagrid, it's OK, but I don't know how to sort data in this IList (ex : m_Name DESC) so that I want to change it to a datatable (or dataset) to use the dataview to sort data.
    How to do that???

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    The only way I know of to convert an IList into a DataTable/DataSet is to loop through the items and add them to a DataTable, as I showed in my previous post.

    If you simply want to sort the IList, try this:
    Code:
    public IList Sort(IList list)
    {
        ((ArrayList)list).Sort();
        return list;
    }
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Replies: 0
    Last Post: 05-01-2003, 05:42 PM
  2. Replies: 0
    Last Post: 03-01-2003, 08:17 AM
  3. Loading XML data into DataSet w/ different schema
    By Michael Koehmstedt in forum XML
    Replies: 1
    Last Post: 11-07-2002, 08:05 PM
  4. Turbo Data: test data generator (www.turbodata.ca)
    By Peter Prager (Canam Software) in forum vb.announcements
    Replies: 0
    Last Post: 08-15-2001, 10:48 AM
  5. Complex Data Consumer Data Aware Classes
    By Desmond Cassidy in forum authorevents.kurata
    Replies: 3
    Last Post: 04-19-2000, 03:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links