M
myotheraccount
Hello,
Is there a way to convert a DataRow to a StringArray, without looping
through all of the items of the DataRow?
Basically, I'm trying to get the results of a query and put them into
a listbox.
Right now it is done like this:
foreach(DataRow myDatarow in myDataTable)
{
String[] row = new String[myDataRow.ItemArray.Length];
for (int x = 0; x < myDataRow.ItemArray.Length; x++)
{
row[x] = myDataRow[x].ToString();
}
myListBox.Items.Add(new ListViewItem(row));
}
Unfortunately, the performance on this is poor when there is a lot of
data.
The number of columns in the DataTable depend on user input, so I
cannot simply replace all of that with
foreach(DataRow myDatarow in my DataTable)
{
myListBox.Items.Add(new ListViewItem (new String [] {
myDataRow["col1"].toString(),
myDataRow["col2"].toString(),
myDataRow["col3"].toString()
...
}
}
Any suggestions?
Thanks in advance
Is there a way to convert a DataRow to a StringArray, without looping
through all of the items of the DataRow?
Basically, I'm trying to get the results of a query and put them into
a listbox.
Right now it is done like this:
foreach(DataRow myDatarow in myDataTable)
{
String[] row = new String[myDataRow.ItemArray.Length];
for (int x = 0; x < myDataRow.ItemArray.Length; x++)
{
row[x] = myDataRow[x].ToString();
}
myListBox.Items.Add(new ListViewItem(row));
}
Unfortunately, the performance on this is poor when there is a lot of
data.
The number of columns in the DataTable depend on user input, so I
cannot simply replace all of that with
foreach(DataRow myDatarow in my DataTable)
{
myListBox.Items.Add(new ListViewItem (new String [] {
myDataRow["col1"].toString(),
myDataRow["col2"].toString(),
myDataRow["col3"].toString()
...
}
}
Any suggestions?
Thanks in advance