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

GetCellElement / GetRowElement always returning nothing

3 Answers 391 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 15 Oct 2010, 11:36 AM
Hi,

I have a RadGridView control, which has 9 columns, created at design time. The control is being populated with data at run-time.

I am populating the RadGridView by using the Add method:

RadGridView1.MasterTemplate.Rows.Add(... some values...)

After populating I am iterating each row in the control as follows:

For Each row As GridViewRowInfo In RadGridView1.MasterTemplate.Rows

I want to get the cell element for the second cell, which I believe I have do do with the GetCellElement method:

RadGridView1.TableElement.GetCellElement(row, RadGridView1.MasterTemplate.Columns(1))

However, GetCellElement is always returning Nothing. I can step through the code using the debugger, and both the column and row exist. I have tested GetRowElement, and this also returns nothing.

I need the CellElement as I want to enable and disable the cell based on some criteria. Each row potentially contains child rows.

Why do I always get nothing? Is there a problem with the way I am using GetCellElement, or do I need to iterate the rows differently?

*EDIT* Forgot to say, I am using the latest version of the Telerik controls (Q2 2010 SP2).

Thanks in advance,
Matt.

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 15 Oct 2010, 11:44 AM
Hi, 

Because of the new layout system that RadGridView uses you cannot get to the CellElement when iterating over the Grid. You should handle the 
RowFormatting and CellFormatting events on the RadGridView to be able to get to the CellElement. 

Hope that helps
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 15 Oct 2010, 11:45 AM
There is an article here that also may help
Let me know if you need more info 
Richard
0
Matt
Top achievements
Rank 1
answered on 15 Oct 2010, 12:21 PM
Thanks Richard, that worked a treat!

Matt.
Tags
GridView
Asked by
Matt
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Matt
Top achievements
Rank 1
Share this question
or