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

[Solved] grid view cell validating

5 Answers 160 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sulagna
Top achievements
Rank 1
sulagna asked on 21 Dec 2010, 02:33 PM

Hi,

How to iterate through each row inside cell validating event. I am getting gridview.ItemSource inside cell validating event but not getting gridview.ItemSource.Count.I need to iterate through each row in that gridview.I am also not getting gridview.Columns or gridview.Rows

How can I loop through ?Please help.

Thanks,
Sulagna

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Dec 2010, 02:46 PM
Hi sulagna,

If you want to validate the rows, you may use the RowValidating and RowValidated events of the RadGridView. Considering the way of getting the count of the items, you need to work with the Items collection of the grid, not its ItemsSource.
 

Regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 22 Dec 2010, 06:17 AM
No I have written separate row_validating event for row validation.I need to validate each cell in a perticular column.My requirement is I need to iterate through each row and assign the cell value of the column to variable. How can I do that?

Regards,
Sulagna
0
Maya
Telerik team
answered on 22 Dec 2010, 08:22 AM
Hello sulagna,

The recommended approach is to work directly with the data item, not the visual elements. So, if you want to update th values in a particular column, you may run through the Items collection and assign the desired value to the corresponding property:

foreach(Player player in this.playersGrid.Items)
{
    player.Number = 42;
}
 

Best wishes,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Matthew
Top achievements
Rank 1
answered on 17 Oct 2011, 10:06 PM
Thank you for this article, I spent countless hours trying to figure out how to do this and was very frustrated not being able to use something like...

foreach (GridViewRow row in radGridView1.Rows)
{
...
}
0
Maya
Telerik team
answered on 18 Oct 2011, 06:58 AM
Hi Matthew,

It is always recommended to work with the data items, not with the visual elements. Since the virtualization of RadGridView is turned on by default, all those visual elements will be recycled and recreated on scrolling. Thus using the rows of the grid will enable you to work only with the visual GridViewRow-s as only they are created.
 

Greetings,
Maya
the Telerik team

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

Tags
GridView
Asked by
sulagna
Top achievements
Rank 1
Answers by
Maya
Telerik team
sulagna
Top achievements
Rank 1
Matthew
Top achievements
Rank 1
Share this question
or