GridViewRow.RowIndex

2 posts, 0 answers
  1. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 07 Jun 2012 Link to this post

    I'm trying to determine the index of a row that was the target row of the context menu.  I can get the row, but in order to get the index of the row, the examples/responses in other posts is to do the following:

    radGridView.Items.IndexOf(clickedGridRow.DataContext);

    Does this loop through each row until you have matched the data item, and then return the index of the loop?

    Why can't GridViewRow simply have a RowIndex property?  Surely there is a way to get this value without looping over the collection.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1217 posts

    Posted 11 Jun 2012 Link to this post

    Hi,

    The recommended approach to retrieve a row's index is to use the following method:
    radGridView.ItemContainerGenerator.IndexFromContainer(row);

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top