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

Access EditForm controls externally

2 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jamel
Top achievements
Rank 1
Jamel asked on 26 Feb 2013, 01:49 PM
I'm trying to access EditForm controls from a different method on the same page.

I'm using the following method but I keep getting null for GridEditableItem. Help?

Protected Sub NumericTextBoxChanged(ByVal sender As Object, ByVal e As EventArgs)
     
    Dim grid As RadGrid = AddEditQuoteFormView.FindControl("ItemsRadGrid")
 
    Dim editItem As GridEditableItem = CType(grid.MasterTableView.GetItems(GridItemType.EditItem)(0), GridEditableItem)
     
    Dim lengthNumericTextBox As RadNumericTextBox = CType(editItem("Length").Controls(0), RadNumericTextBox)
    Dim length = lengthNumericTextBox.Value
 
    CalculateFreightClass(length, width, height, weight)
 
End Sub

2 Answers, 1 is accepted

Sort by
0
Jamel
Top achievements
Rank 1
answered on 26 Feb 2013, 02:28 PM
Okay, so I didn't wait for Telerik (frankly it would've been days before anyone on this forum gives me a proper answer). Here is the correct code for anyone who needs help accessing GridEditFormInsertItem controls externally.

Protected Sub NumericTextBoxChanged(ByVal sender As Object, ByVal e As EventArgs)
      
    ' Find the grid and reference it
    Dim grid As RadGrid = AddEditQuoteFormView.FindControl("ItemsRadGrid")
  
    ' Here is the correction. This returns a GridEditFormInsertItem with all of the controls that are being edited.
    Dim editItem As GridEditFormInsertItem = grid.MasterTableView.GetItems(GridItemType.EditFormItem)(0)
      
    ' Find the control and reference it
    Dim lengthNumericTextBox As RadNumericTextBox = CType(editItem("Length").Controls(0), RadNumericTextBox)
    Dim length = lengthNumericTextBox.Value ' Extract the value
  
    CalculateFreightClass(length, width, height, weight)
  
End Sub
0
Andrey
Telerik team
answered on 01 Mar 2013, 09:31 AM
Hello,

Yes, this is the right approach to access the Grid items from an external method.

Additionally, please note that when you are posting a forum thread you are depending solely on the community and the response time is not guaranteed. Sometimes it could a little longer for the community to respond.

All the best,
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
Jamel
Top achievements
Rank 1
Answers by
Jamel
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or