How can I convert DataRow to string Array?

Shashank picture Shashank · Sep 20, 2010 · Viewed 68k times · Source

I have some values in a DataGridRow (item Array) and I want to fetch all these values into a string array. How can I achieve this?

DataGridRow row = (DataGridRow)Lst.ItemContainerGenerator.ContainerFromIndex(k);
            DataRowView Drv = (DataRowView)row.Item;
            DataRow dr = (DataRow)Drv.Row;

Answer

Jiss picture Jiss · Apr 18, 2012
var rowAsString = string.Join(", ", dataTable.Rows[0].ItemArray); 

No need of any lambda expresion as above.