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

Get values from cell (order)

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wnl
Top achievements
Rank 1
wnl asked on 14 Sep 2011, 03:28 PM
Hi, I want to get values from grid from two columns.
I have a function for getting values from one column:

string tmp = String.Empty;
            if (rg.SelectedItems.Count > 0)
            {
                int i = 0;
                foreach (GridDataItem DataItem in RadGrid.SelectedItems)
                {
                    TableCell cell = DataItem[columnName];
                    if (cell.Text.Length > 0 && cell.Text != " ")
                    {
                        tmp = String.Format("{0}{1}{2}", tmp, i > 0 ? ";" : "", cell.Text);
                    }
                    i++;
                }
            }
            return tmp;
For example my grid contains data:
Column1  Column2 Column3
1    2 3
4    5 6
7    8 9
If I execute code 2 times (for Column1 and Column3, could I be sure thay values will be:
"1;7" and "3;9" (right order, from top to bottom in those 2 cases)?
 Or the order could be random for example: "1;7" and "9, 3"?

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 19 Sep 2011, 02:01 PM
Hi Wnl,

Items are added to the SelectedItems collection in the exact order they are selected. So if the selected items remains the same, then yes you could be sure what is the order. But if you are using AJAX and in case every checkbox makes post-back, then it is possible if the user checks them too fast, some of the selected items are not added to the collection. To prevent this you should wrap the grid in panel.

Regards,
Andrey
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
Grid
Asked by
wnl
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or