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

Selected row

1 Answer 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tzahi
Top achievements
Rank 1
tzahi asked on 05 Jun 2011, 04:23 PM
Hey,

in a regular gridview I can easily get the number of the row which was selected.
dataGridView1.Rows[0].Selected = true;


somehow, I can't get it in a radGrid.

I tried:
string selectedValue = (RadGrid1.SelectedItems[0] as GridDataItem)["users"].Text;

but I keep getting excaption:
"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"

Can anyone point out this code?

Thx

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jun 2011, 04:57 AM
Hello Tzahi,

In order to get the selected row, loop through each item and then access the row.

C#:
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridDataItem item in RadGrid2.SelectedItems)
 {
string selectedValue = (RadGrid2.SelectedItems[0] as GridDataItem)["users"].Text;
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
tzahi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or