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

Access insert item

2 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
eric
Top achievements
Rank 1
eric asked on 26 Oct 2009, 11:34 PM
I have a radgrid that uses a usercontrol as an editform.  How can I access the user control for the item being inserted?  I need to access the insert control from an ajax request.    Apparently this is different from accessing an edit control?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Oct 2009, 07:49 AM
Hello Eric,

You can try out the following code to access a control in the insert form:
c#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted) 
        { 
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item; 
            UserControl userControl = (UserControl)insertItem.FindControl(GridEditFormItem.EditFormUserControlID); 
            Control cntrl = (Control)userControl.FindControl("ControlID"); 
        } 
    } 
 

Thanks
Princy.
0
eric
Top achievements
Rank 1
answered on 27 Oct 2009, 11:23 PM
Thanks Princy, that works for grid events but not for the scenario I presented.  This is what I ended up doing....

 

 

Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager.AjaxRequest

 

            Dim uc As New UserControl  
            For Each item As GridDataItem In rgManageUsers.Items  
 
                uc = DirectCast(item.OwnerTableView.GetInsertItem().FindControl(GridEditFormItem.EditFormUserControlID), UserControl)  
            Next 
End Sub

 

 

 

 

 

 

Tags
Grid
Asked by
eric
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
eric
Top achievements
Rank 1
Share this question
or