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

[Solved] How to reference the Edit Form (web user control) from GridItemEventArgs?

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brad Hehe
Top achievements
Rank 1
Brad Hehe asked on 23 Sep 2009, 05:18 PM
The examples I've found thus far have shown accessing the EditForm (which is a seperate UserControl in PopUp edit mode) via events that have the GridCommandEventArgs...  I took a quick stab at trying to find the UserControl via the GridItemEventArgs (as I would be using if I need to reference the UserControl during the ItemCreated / ItemDataBound events) but I ran into issues...

From the other examples I've used this code for retrieving the UserControl from the GridCommandEventArgs type:
Args: [GridCommandEventArgs e]  
Code: object eeditFormUserControl = e.Item.FindControl(GridEditFormItem.EditFormUserControlID); 

I tried to follow the same pattern above (i.e. during the ItemDataBound event when the Item is a GridEditFormInsertItem/GridEditFormItem) but didn't quite get what I was needing to do from there...

I'm trying to make a utility function in my base class where it is overloaded with both EventArg types and simply returns my user control....

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 25 Sep 2009, 12:04 PM
Hello Brad,

The best place to access the EditForm are the ItemCreated / ItemDataCound event handlers. In the you can use the following code:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem item = (GridEditFormItem)e.Item;
            UserControl userControl = (UserControl)item.FindControl(GridEditFormItem.EditFormUserControlID); //the usercontrol 
            //you can modify it here 
        } 
    } 

Best wishes,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Brad Hehe
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or