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

how to pass telerik controls by reference

1 Answer 187 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Software asked on 16 Jun 2016, 12:54 PM

Hi, I am new to Telerik and ASP.NET, but not to programming.  I have multiple controls (radcomboboxes, text fields) repeated in rows of a table. Each row's field names are appended with a digit to differentiate(ddlChild1, ddlChild2, etc.). I am wanting to modify 4 of the controls in that row, based on the selection of in the combo box (ddlChildx).  I am trying to minimize the code needed, so instead of having a block of code and duplicating it 10 times for each of the rows/controls' SelectedIndexChanged event, I wanted to pass the controls in the row to a function or subroutine by reference.  However, when I try to declare the parameters 'As Telerik.RadComboBox', it lists Telerik as a namespace not a class in the pop up help when writing out the code.  So, it isn't able to bring up the Methods in that parameter.  

What do I need to do for the subroutine or function to recognize the telerik control so I can pass it by reference and just do changes to the .SelectedValues or .Text in my subroutine or function.  I tried just defining the parameters as dropdownbox, but in compile it said that I couldn't pass the Telerik control to the function

Thanks in advance for your help.

Here's the code to call the function for one of the rows:

Public Sub ddlChild1_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs) Handles ddlChild1.SelectedIndexChanged
        'Child Selected Now Default other fields
        Dim intPos As Integer

        intPos = InStr(ddlChild1.Text, "-")
        If intPos <> 0 Then
            If Mid(ddlChild1.Text, intPos + 1, 3) = "000" Then
                'Not a Child
                If Mid(ddlChild1.Text, intPos - 1, 2) = "MG" Then
                    ddlAccount1.SelectedValue = "MG"
                End If
            Else
                'Child
                'Get Next Applied From and To Dates
                Functions.fGetAppliedFromTo(ddlChild1, ddlAccount1, txtFrom1, TxtTo1)
                'Get Next Support Due
                Functions.fGetAmountOwed(ddlChild1, txtAmount1)

            End If
        End If
    End Sub

 

Here's the beginning of one of the functions:

 Public Shared Function GetAppliedFromTo(ByRef ddlChild As DropDownList, ByRef ddlAccount As DropDownList, ByRef txtFrom As TextBox, ByRef txtTo As TextBox)

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Software
Top achievements
Rank 1
answered on 16 Jun 2016, 01:35 PM

Found the answer:  It needs:

 

Telerik.Web.UI.RadComboBox 

Tags
General Discussions
Asked by
Software
Top achievements
Rank 1
Answers by
Software
Top achievements
Rank 1
Share this question
or