tags:

views:

93

answers:

2

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;
A: 

One possibility is to call dr.ItemArray; This will get you a object[]. Then you have to cast each object to string before you use it.

Øyvind Bråthen
A: 
var rowAsString = string.Join(", ", dr.Selct(c => c.ToString()).ToArray());

This should give you a string with each item in your data row separated by a comma.

Rune Grimstad