RadGrid for ASP.NET AJAX

RadControls for ASP.NET AJAX

In some occasions you may want to display row numbers in Telerik RadGrid - for example to correlate the grid items when exporting the control's structure to Excel or just for easier navigation/access. The functionality is not built-in in the product, however such layout is achievable with a few lines of code:

  1. Subscribe to the ItemDataBound event of the grid

  2. Check whether the currently bound item is GridDataItem

  3. Extract the ItemIndex of the e.Item instance and display its value in a control residing in GridTemplateColumn's ItemTemplate.

In the example code below the item index is presented in MS Label control which is wrapped in template column: