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

[Solved] Simplest Way To Programmatically Access Cell Cotent

5 Answers 189 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Andrew asked on 20 Aug 2010, 12:44 PM
If I only have access, in running code, to a RadGridView, what is the simplest way to access the Content of a cell at, say, Row 3, Column 4?

5 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 20 Aug 2010, 03:33 PM
Hi Andrew,

Please see the following thread and let me know if this works in your scenario.

Greetings,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 23 Aug 2010, 01:55 PM
That would help IF I could figure out exactly how to get the Rows collection when I only have a access to the RadGridView in a given function.

Let's just say my code looks like this:
public void ProcessCells() 
{
    RadGridView grid = GetGrid();
  
    GridViewRow row = // ??? how do I get this from the grid in order to do the following?
  
    foreach (GridViewCell cell in row.Cells) 
    
        if ( cell.Column.UniqueName = "Value"
        {
            //Process Cell
        }
    }
}

How do I get the rows collection, and thus the cells collection, from the grid itself?
0
Milan
Telerik team
answered on 23 Aug 2010, 02:33 PM
Hello Andrew,

I wouldn't recommend you to work with UI element but with the data itself. For example, you can use the Items property of RadGridView to go through all items, cast each one to the correct type and process the item by inspecting its properties.

foreach (Player player in this.playersGrid.Items)
{
    if (player.Country == "")
    {
        // do something
    }
}

How does that sound?


All the best,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dave
Top achievements
Rank 1
answered on 08 Dec 2010, 05:09 AM
I have a similar issue. I need to access a specific cell in order to modify its content. The cell is not bound to the underlying item, it is a templated cell that is built when the grid is loading. So, I can't work with the underlying data item. Is there a way to get to a specific cell/row?
0
Vlad
Telerik team
answered on 08 Dec 2010, 08:23 AM
Hello,

 You can use our ChildrenOfType<T>() extension method to get cells on the screen however working in this way next time when you scroll these cells may not exists or with be associated with different rows/columns. The grid is virtual with container recycling. The standard way in both Silverlight and WPF is MVVM - no matter if you want to consume data or not you will need to bind the controls to your model where you can separate your business logic, listen for commands and values changes. 

Regards,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Andrew
Top achievements
Rank 1
Milan
Telerik team
Dave
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or