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

Get the previous columns cell value of the the selected cell

6 Answers 161 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramasamy
Top achievements
Rank 1
Ramasamy asked on 28 Sep 2011, 07:31 AM
Hi,

I have selected a cell and I want fetch the value of the previous cell of the selected cell. Please let me know how can be get that.

Thanks,
Ramasamy

6 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Sep 2011, 08:38 AM
Hi Ramasamy,

You can handle SelectedCellsChanged event of the grid and work with the AddedCells and RemovedCells collections from the arguments.
 

Best wishes,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ramasamy
Top achievements
Rank 1
answered on 28 Sep 2011, 09:01 AM
Hi Maya,

I have tried with the two methods. But I cannot able to get the previous cell value.

for example,

Selected Row - 5, Column - 5

I want the value present in Row 5 and column 4. How it can achievable?

Thanks,
Ramasamy

0
Maya
Telerik team
answered on 28 Sep 2011, 09:32 AM
Hi Ramasamy,

Has the cell in column 4 been selected ? Nevertheless, you may still get the underlying item and find the value for the property corresponding to column 4. 
 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ramasamy
Top achievements
Rank 1
answered on 28 Sep 2011, 09:36 AM
Hi Maya,

I have selected only the cell 5 but I want the value in cell 4.

Thanks,
Ramasamy
0
Ramasamy
Top achievements
Rank 1
answered on 28 Sep 2011, 10:03 AM
Hi Maya,

I am binding a data table to the self reference gridview and I am able to access the parent grid columns in the code behind as

RadGridView1.Columns[0].IsVisible = false;

How can i do that for the child grid columns. Please help me it will solve lot of my issues.

Thanks,
Ramasamy
0
Maya
Telerik team
answered on 29 Sep 2011, 08:07 AM
Hi Ramasamy,

You can get the corresponding item for a selected cell as follows:

void clubsGrid_SelectedCellsChanged(object sender, GridViewSelectedCellsChangedEventArgs e)
        {
            GridViewCellInfo cellInfo = e.AddedCells[e.AddedCells.Count - 1];
            Club item = cellInfo.Item as Club;
            var name = item.Name;      
        }

Considering how to reach the columns collection of the child grid, you can take a look at this article for a reference.
 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Ramasamy
Top achievements
Rank 1
Answers by
Maya
Telerik team
Ramasamy
Top achievements
Rank 1
Share this question
or