grid view cell validating

6 posts, 0 answers
  1. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 21 Dec 2010 Link to this post

    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

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 21 Dec 2010 Link to this post

    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
  3. sulagna
    sulagna avatar
    56 posts
    Member since:
    Sep 2010

    Posted 22 Dec 2010 Link to this post

    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
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 22 Dec 2010 Link to this post

    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
  5. Matthew
    Matthew avatar
    46 posts
    Member since:
    Aug 2011

    Posted 17 Oct 2011 Link to this post

    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)
    {
    ...
    }
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 Oct 2011 Link to this post

    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 >>

Back to Top