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

Cannot FindControl in ItemCommand event

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 01 Nov 2012, 01:50 PM
I would like to find a user control that I am using in my RadGrid Edittemplate, but I cannot.

I am able to find it in the ItemDataBound event, but I cannot find it at ItemCommand where I need to access a control within it.

This is how I access the usercontrol in ItemDataBound event:

 

 

Protected Sub rg_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)

 

 

 

 If TypeOf (e.Item) Is GridEditFormItem And Not rg.MasterTableView.IsItemInserted Then

 

 

 

   Dim e_item As GridEditFormItem = CType(e.Item, GridEditFormItem)

 

 

 

   Dim uc As UserControl = CType(CType(e.Item, GridEditFormItem).FindControl("EditFormControl"), UserControl)

 

 

 

End If

 

 

 

End Sub

This works but does not in ItemCommand.

 

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 06 Nov 2012, 09:54 AM
Hello,

Why do you wan to access the user control on the ItemCommand event? If you want to handle Update/Delete/Insert commands, there are specific command events for these functions, respectively - UpdateCommand, DeleteCommand, InsertCommand. In these events you could get a reference to the edited item through the event arguments as shown in this help topic.

Additionally, you could check this help topic for more information on how to access user control edit form in RadGrid.

Regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or