how to pass telerik controls by reference

2 posts, 0 answers
  1. Bryon
    Bryon avatar
    9 posts
    Member since:
    Jan 2015

    Posted 16 Jun 2016 Link to this post

    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
                    '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)





  2. Bryon
    Bryon avatar
    9 posts
    Member since:
    Jan 2015

    Posted 16 Jun 2016 in reply to Bryon Link to this post

    Found the answer:  It needs:



Back to Top