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

Accessing controls in an EditTemplate

1 Answer 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tjans
Top achievements
Rank 1
tjans asked on 24 Nov 2008, 09:13 PM

I am using a RadGrid with several editor columns, including a CheckBox, DropDownList (RadComboBox style), and a Template column.

When editing, I'm easily able to get a handle on these controls using the following code:

if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {  
                RadComboBox list = (e.Item as GridEditableItem)["MethodColumn"].Controls[0] as RadComboBox;  
                Prometheus.SetRadComboBoxHeight(list,_maxComboBoxItems,_pixelsPerComboBoxItem);  
                list.AutoPostBack = true;  
                list.SelectedIndexChanged += MethodRadComboBox_SelectedIndexChanged;  
            } 

This works in both the ItemCreated event as well as in the ItemDataBound event of the grid. I've also gotten it to work using the GetColumnEditor function.

But, when adding (by simply setting the MasterTableView.IsItemInserted value = true in a RadToolBar button click), this same code above  does not work.  The GetColumnEditor function returns null, and the method above (...["ColumnName"].Controls[0]) returns a literal object.  Is there something specific I need to do for an "Add" in order to get a handle on these controls?

I've spent the better part of a day on this and frankly, I'm stumped.

1 Answer, 1 is accepted

Sort by
0
tjans
Top achievements
Rank 1
answered on 24 Nov 2008, 09:41 PM
Strange, it started working...I believe part of my confusion stemmed from the fact that I didn't realize that IsInEditMode is true even when IsItemInserted = true. I thought they were mutually exclusive...        
Tags
Grid
Asked by
tjans
Top achievements
Rank 1
Answers by
tjans
Top achievements
Rank 1
Share this question
or