dataset table row into an arraylist

How to put a list of rows from dataset table into an array

I tried with this code but it doesn't help.

ArrayList arrayList = new ArrayList();

foreach
(DataRow dr in db.dataSetUsers.Tables["Functions"].Rows)

{

arrayList.Add (dr["Name"]);

}



Answer this question

dataset table row into an arraylist

  • M.Davoodi

    Hi,

    Simplest option..Just call a Select on the DataTable with a blank string for filter.


    DataRow []arrDataRow = null;
    arrDataRow = db.dataSetUsers.Tables["Functions"].Select("");

     


    This will give u an array of rows. (not an ArrayList)

    Regards,
    Vikram

  • WineMan

    Do you want to store the DataRow or the values from the DataRow

    In you code you are storing the value from the Name column in the ArrayList.

    you can use the following code to add the compelete DataRow into an ArrayList

    arrayList.Add( dr) ;

  • dataset table row into an arraylist