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

Accessing columns by index

2 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kate
Top achievements
Rank 1
Kate asked on 28 Jul 2014, 05:58 PM
Is there any way to access a column using its index? I have a radgrid with AutoGenerated columns so I have no idea what the column name is but I can access the index.

Basically, I want to get the header of the column that's being updated. I could do this if i could use index but I don't see that as an option. 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Jul 2014, 03:22 AM
Hi Kate,

Please try the following code snippet to access the column using index:

C#:
string headerText = RadGridSample.MasterTableView.AutoGeneratedColumns[3].HeaderText;

Thanks,
Princy
0
Kate
Top achievements
Rank 1
answered on 29 Jul 2014, 12:10 PM
Thanks Princy. I had to access the column of the cell I was editing within a loop of all the cells in the row. So I used this solution:

 for (int i = 5; i < row.Cells.Count; i++)
 {
      //create grid header item then access the header for the current cell and assign to productcatalogfamily
      GridHeaderItem headerItem = radDiscounts.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
      string strProductCatalogFamily = headerItem.OwnerTableView.ColumnSettings[i].UniqueName.ToString();
}

Thanks again for your response.
Tags
Grid
Asked by
Kate
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kate
Top achievements
Rank 1
Share this question
or