This question is locked. New answers and comments are not allowed.
Hello,
I have unique grid that is using SL lightweight datatable to populate cells in my RadGridView. I have to use it because my grid is dynamically created as per users preference about number of rows and columns.
I have to bind blank rows initially and later user populate the data inside the cells using separate form view. When user select cell I have to fetch data from DB and populate that on form view. In order to do so I need to know row index and column index of selected cell.
I can find column index easily but problem lies in row index because data in each cell is empty string and RadGridview is trying to lookup data based on datacontext as below:
I have unique grid that is using SL lightweight datatable to populate cells in my RadGridView. I have to use it because my grid is dynamically created as per users preference about number of rows and columns.
I have to bind blank rows initially and later user populate the data inside the cells using separate form view. When user select cell I have to fetch data from DB and populate that on form view. In order to do so I need to know row index and column index of selected cell.
I can find column index easily but problem lies in row index because data in each cell is empty string and RadGridview is trying to lookup data based on datacontext as below:
RadGridView1.Items.IndexOf(RadGridView1.CurrentCell) here is my Xaml:Here is my codebehind:<telerik:RadGridViewx:Name="RadGridView1"AutoExpandGroups="True"RowIndicatorVisibility="Collapsed"Grid.Row="1"SelectionUnit="FullRow"CurrentCellChanged="RadGridView1_CurrentCellChanged"SelectedCellsChanged="RadGridView1_SelectedCellsChanged"SelectionChanged="RadGridView1_SelectionChanged"/>I tried using both types of selectionunit (cell,fullrow), but none worked. Is there anyway to get selected row index using some other event? I go through documentation but no help so far. Thanks in advance. -Vedant NOTE: you need to get data.cs and dynamic.cs classes in your project from hereDataTable table =null;publicMainPage(){InitializeComponent();Random rnd =newRandom();table =newDataTable();for(inti = 0; i <= 5; i++){var coln ="col "+ i.ToString();table.Columns.Add(newDataColumn() { ColumnName = coln, DataType =typeof(string) });}for(var r = 0; r < 10; r++){DataRow row =newDataRow();for(intc = 0; c <= 5; c++){var coln ="col "+ c.ToString();row[coln] ="Hello";}table.Rows.Add(row);}RadGridView1.ItemsSource = table.ToList();}privatevoidRadGridView1_CurrentCellChanged(objectsender, Telerik.Windows.Controls.GridViewCurrentCellChangedEventArgs e){txtitems.Text ="you selected Row "+ RadGridView1.Items.IndexOf(RadGridView1.CurrentCell)+" Column "+ e.NewCell.Column.DisplayIndex;}privatevoidRadGridView1_SelectionChanged(objectsender, Telerik.Windows.Controls.SelectionChangeEventArgs e){}privatevoidRadGridView1_SelectedCellsChanged(objectsender, Telerik.Windows.Controls.GridView.GridViewSelectedCellsChangedEventArgs e){//txtitems.Text = "you selected Row " + RadGridView1.Items.IndexOf(e.AddedCells[0].Item)// + " Column " + e.AddedCells[0].Column.DisplayIndex;}}