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

Loop through grid - reading cell values?

6 Answers 137 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 22 Jun 2012, 09:21 PM
When a user clicks a button I want to loop through the entire grid, row by row, reading the value of a specific column cell.

Can you tell me the easiest, most efficient way to accomplish this?

Thank you very much.

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Jun 2012, 07:00 AM
Hello,

Since the RadGridView supports UI Virtualization, it is not recommended to work with the visual elements (i.e. GridViewRows, GridViewCells) and their properties.

May I ask you to share what your final goal is? 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ben
Top achievements
Rank 1
answered on 25 Jun 2012, 01:47 PM
I load the grid from a SQL stored procedure.  Because of some security conditions and business rules, I treat the grid as a disconnected data set.

Users make changes.  When they click the 'Save' button, I want to read through each row of the grid, check the data against our business rules, then run a stored procedure to update the data row by row. 

All I really want to do is look at the grid values in the code behind.  Can anyone tell me the simplest way to accomplish this?  I'm new to the Telerik suite.  This is a newbie question.

Thank you.
0
Dimitrina
Telerik team
answered on 25 Jun 2012, 03:13 PM
Hello,

Based on your description, I would suggest you to iterate through the Items collection of the RadGridView and validate each item against your business rules. 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ben
Top achievements
Rank 1
answered on 25 Jun 2012, 03:28 PM
That's what I would like to do.  Can you please post some code that shows me how I can access the values in each row?  I'm having trouble understanding how to get at these values in the code behind.  Thank you.
0
Accepted
Dimitrina
Telerik team
answered on 27 Jun 2012, 03:56 PM
Hello,

 I have attached the sample project suggested to you from my colleague in your other thread so that it is available to the whole community.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ben
Top achievements
Rank 1
answered on 27 Jun 2012, 08:53 PM
This is just what I need.  Thank you.
Tags
GridView
Asked by
Ben
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Ben
Top achievements
Rank 1
Share this question
or