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

Iterate through DataSource of a grid

3 Answers 425 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Love
Top achievements
Rank 1
Michael Love asked on 21 Apr 2010, 03:08 PM
Hi there.

How would I iterate through the DataSource of a grid? I have items that are not in a column, but are part of the datasource that I need to get at.

Thanks, Mike

3 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 21 Apr 2010, 04:51 PM
You can handle the ItemDatabound event of the RadGrid and cast the DataItem object to get at the columns you need.

I hope that helps.
0
Michael Love
Top achievements
Rank 1
answered on 21 Apr 2010, 04:53 PM
Hi Robert.

Thanks for the reply. I need to do it when processing a button click.

Mike
0
robertw102
Top achievements
Rank 1
answered on 21 Apr 2010, 07:04 PM
In that case, you could add them to the DataKeyNames collection of your RadGrid and then access them in the button click. Like so:

foreach (GridDataItem item in RadGrid1.Items) 
            { 
                item.GetDataKeyValue("DataKeyName"); 
            } 

You can iterate through the items collection and then pass the DataKeyName that you want to know the value of.

I hope that helps.
Tags
Grid
Asked by
Michael Love
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Michael Love
Top achievements
Rank 1
Share this question
or