I tried to use "foreach" and "for" to get all rows in the demo of GridView Folder tree, but failed
for (int i = 0; i < radGridView1.Rows.Count; i++)
{} foreach (GridViewRowInfo fvri in radGridView1.Rows) {}
1 Answer, 1 is accepted
0
Stefan
Telerik team
answered on 15 Sep 2010, 03:39 PM
Hello hon,
Thank you for contacting us.
Your code seems to be correct, so may be the problem is that it is located in the wrong place. If you are trying to do this in the form constructor, you should be aware that the at this moment the rows are still not created. I would suggest that you try executing the code snippet in the form's Shown event or even in DataBindingComplete event, where all rows are created. Please refer to the following code sample:
Please note that the Rows collection of RadGridView, when it is in self-referencing hierarchy mode, returns all data items of the flat source that is binded to RadGridView. The Rows collection in the Folder Tree example should return 41, which is the also number of the data rows in the data table returned by the CreateDataSource() method.
Additionally, since as I said I do not know exactly why do you need it, you might want to take a look at the RowFormatting event, in case you want to visually format the rows.
Further information about RadGridView visual rows can be found in this help article.
I hope you find this information helpful. However, if this does not work for you, can you please provide me with a details description of what exactly are you trying to achieve? This will allow me to point you in the right direction.
Best wishes,
Stefan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items