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

finding the row index in the item data bound event

3 Answers 1332 Views
Grid
This is a migrated thread and some comments may be shown as answers.
andieje
Top achievements
Rank 1
andieje asked on 26 Nov 2008, 06:56 PM
Hi
I am using radgrid 5.1.2
I am sure this is an obvious question but I can't find it in the documentation. How do i find the row index of the grid in the item data bound event
thanks

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 Nov 2008, 07:19 PM
Hello Andieje,

I suggest you test the following approach in order to get the desired index:

Table row index
int rowIndex = e.Item.RowIndex; 

Grid item index
int itemIndex = e.Item.ItemIndex; 

Let us know if you need more information.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
steve
Top achievements
Rank 1
answered on 11 Jul 2012, 10:16 AM
Is there a way to find out grid cell index? In the following example, value of 'column' variable gives us table cell index. How can i get grid cell index like for rows?

int column = 0;
foreach (GridTableCell cell in ((GridDataItem)e.Item).Cells)  { column++; ... }

0
Princy
Top achievements
Rank 2
answered on 11 Jul 2012, 10:57 AM
Hi Steve,

Here is the sample code I tried to get the cell indexes of rows.The column index starts at index 2 because GridExpandColumn and GridRowindicatorColumn are always in front of data columns.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
   if (e.Item is GridDataItem)
   {
       foreach (GridColumn col in RadGrid1.MasterTableView.Columns)
       {           
            int ColumnIndex = col.OrderIndex;
            string ColumnUniqueName = col.UniqueName;          
       
   
}

Thanks,
Princy.
Tags
Grid
Asked by
andieje
Top achievements
Rank 1
Answers by
Daniel
Telerik team
steve
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or