Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Problem to Find controls in addnewrow event
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Problem to Find controls in addnewrow event

Feed from this thread
  • Manuel avatar

    Posted on Jun 15, 2011 (permalink)

    Hi

    I have a problem witn an object inside a radgrid, I´m trying to refill a DROPDOWNLIST inside a RADGRID using the characters entered in a textbox that is outside the RADGRID, but i can´t find the DROPDOWNLIST.  This code snippet works correctly when editing a record in the radgrid but the object (dropdownlist) can´t be founded at the moment of adding a new record on it.  This is the code snippet:


    For Each item As Telerik.Web.UI.GridDataItem In RadGrid1.MasterTableView.Items
        Dim DDL_CODIGO_CUENTA As DropDownList = CType(item.FindControl("DDL_CODIGO_CUENTA"), DropDownList)
        If TypeOf DDL_CODIGO_CUENTA Is DropDownList Then
          cWhere_Tmp = cWhere_Tmp & " AND NOMBRE_CUENTA LIKE '%" & TXN_BUSCAR.Text & "%'"
          If Convert.ToString(ViewState("Estado")) = "RadGrid1_Editar" Then
            cWhere_Tmp = "(" & cWhere_Tmp & ") OR CODIGO_CUENTA = '" & Sustraer_Codigo_Cuenta(DDL_CODIGO_CUENTA.SelectedValue) & "'"
          End If 'Convert.ToString(ViewState("Estado")) = "RadGrid1_Editar" Then
          cError = Llenar_Lista_Cuentas(cOleDbCnn, item, DDL_CODIGO_CUENTA.SelectedValue, cWhere_Tmp)
          If cError <> "" Then
            Aplicar_Filtro_Cuentas = cError
            Exit Function
          End If 'cError <> "" Then
        End If 'TypeOf DDL_CODIGO_CUENTA Is DropDownList Then
      Next

    Thanks in advance.


  • Posted on Jun 16, 2011 (permalink)

    Hello Manuel,

    You can access the DropDownlist by using findControl().
    VB:
    Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
        If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
            Dim edititem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
            Dim drp As DropDownList = DirectCast(edititem.FindControl("DropdownList1"), DropDownList)
        End If
    End Sub

    Thanks,
    Shinu.

  • Manuel avatar

    Posted on Jun 16, 2011 (permalink)

    Hello Shinu, thaks, i have tried that, but what I want is to refill the DROPDOWNLIST (in the addnewrow event) from a button that is outside the RADGRID, like the TEXTBOX and refresh it each time the button is pressed taking the characters from the textbox as a filter.

  • Posted on Jun 17, 2011 (permalink)

    Hello Manuel,

    You can access the InsertForm in an external event as shown below. Hope this helps.

    VB:
    If RadGrid1.MasterTableView.IsItemInserted Then
        Dim item1 As GridEditFormInsertItem = DirectCast(RadGrid1.MasterTableView.GetInsertItem(), GridEditFormInsertItem)
        Dim ddl As DropDownList = DirectCast(item1.FindControl("dropdown"), DropDownList)
        RadGrid1.MasterTableView.Rebind()
    End If

    Thanks,
    Princy.

  • Manuel avatar

    Posted on Jun 20, 2011 (permalink)

    Thank you very much, it works, I can find the control now and make the routine that inserts the new list, but I can´t refresh the control to make appear that new list.  Do you have any idea?  Thak you very much again.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Problem to Find controls in addnewrow event