I want to insert an arraylist in Datarow.
using this code,
ArrayList array=new ArrayList();
foreach (string s in array)
{
valuesdata.Rows.Add(s);
}
But My datatable must have only one datarow. My code created eight datarows. I tried,
valuesdata.Rows.Add(array);
But it doesn't work.That should be
valuesdata.Rows.Add(array[0],array[1],array[2],array[3]....);
How can I solve this problem?
Thanks.
List<string>
debracey 2012-04-04 01:37
try this:
ArrayList array = new ArrayList();
String[] arrayB = new String[array.Count];
for (int i = 0; i < array.Count; i++)
{
arrayB[i] = array[i].ToString();
}
valuesdata.Rows.Add(arrayB);
try like this:
//1 - declare the array ArrayList object
ArrayList array = new ArrayList();
//2 - here add some elements into your array object
//3 - convert the ArrayList to string array and pass it as ItemArray to Rows.Add
valuesdata.Rows.Add(array.ToArray(typeof(string)));
array
variable first - debracey 2012-04-03 23:21