Access item through index.

2 posts, 0 answers
  1. Jane
    Jane avatar
    13 posts
    Member since:
    Aug 2013

    Posted 13 Aug 2013 Link to this post

    Hi Telerik,

    I am about to replace the asp datagrid in my page with radgrid and there I frequently used indexes to access the grid items and found telerik grid rarely use the same approach in samples available over the internet. So is there any disadvantages of using index in telerik radgrid apart from asp gridview. In such a case i need to alter a major portion of my code.

    Thanks and Regards,
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Aug 2013 Link to this post

    Hi Jane,

    Telerik RadGrid has a property called UniqueName of string type which provides a reliable way of locating the cell in a particular column. This property is assigned automatically at design time. For example, an auto-generated GridBoundColumn with DataField 'ContactName' generates a UniqueName of 'ContactName'.

    One of the major differences between RadGrid and the standard .NET DataGrid control is the dynamic column structure of RadGrid. Unlike the MS DataGrid, RadGrid supports operations such as column reordering and grouping at client which alter the Cells collection of GridItem objects in a way that can’t be predicted by the page developer. But imagine that the user has changed the column order using client-side drag/drop. Then the cell with index 4 will no longer refer the same field value. That's why RadGrid provides the ability to access cells in items using the corresponding column’s UniqueName. For example, if you have a column with the unique name "CustomerID" you can find the corresponding cell in a GridItem even if the column is reordered at client and hence it is always preferable to use UniqueName instead of index.


Back to Top