This is a migrated thread and some comments may be shown as answers.

How can I Transfer data to DataTable

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lena
Top achievements
Rank 1
Lena asked on 25 Jul 2008, 05:59 AM
Hello,
I have RadGrid object, which populating by SPView. I turn on multy-select option. Then I choose some Items and try to add them in DataRow. But it doesnt work. There  belove is my code which I use:

DataTable

dtTemp = new DataTable();

dtTemp.Columns.Add(

new DataColumn("SelectTasks", typeof(String)));

dtTemp.Columns.Add(

new DataColumn("TaskID", typeof(String)));

dtTemp.Columns.Add(

new DataColumn("Naznahenie", typeof(String)));

foreach (GridDataItem item in RadGrid1.SelectedItems)

{

DataRow dr = dtTemp.NewRow();

dr[

"SelectTasks"] = (String)item.Cells[0].Text;

dr[

"TaskID"] = (String)item.Cells[1].Text;

dr[

"Naznahenie"] = (String)item.Cells[2].Text;

dtTemp.Rows.Add(dr);

}


Please help to resolve this problem

Best Regards

1 Answer, 1 is accepted

Sort by
0
Nikita Gourme
Top achievements
Rank 1
answered on 28 Jul 2008, 01:20 PM
To ensure that you will reference the proper cell values from the selected rows, use the unique name of the column or DataKeyNames/DataKeyValues. Indexing the Cells collection is not efficient when you have grouping/column reordering or other grid features which change the cell indices.

Nikita
Tags
Grid
Asked by
Lena
Top achievements
Rank 1
Answers by
Nikita Gourme
Top achievements
Rank 1
Share this question
or