RadComboBox OnSelectedIndexChanged

3 posts, 1 answers
  1. Bill
    Bill avatar
    3 posts
    Member since:
    Jul 2011

    Posted 01 Aug 2011 Link to this post

    I am trying to use the Selected index of one RadComboBox help build the query to populate another RadComboBox, they are both in the <EditItemTemplate>.
    I get an Object reference not set to instance of an object when I run this code just adding a RadComboBoxItem without even building the query.

    Protected Sub ItemType_SelectedIndexChanged(ByVal o As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
    Dim DDL As RadComboBox = TryCast(RadGrid1.FindControl("FlatFileType").Controls(0), RadComboBox)
    Dim RadComboBoxItem1 As New RadComboBoxItem("First Item")
    DDL.Items.Add(RadComboBoxItem1)
    End Sub

    I am not sure how to correctly access the second radcombobox to be able to populate it.
    Any help is greatly appreciated.

  2. Answer
    Thad
    Thad avatar
    106 posts
    Member since:
    Sep 2010

    Posted 01 Aug 2011 Link to this post

    Hi Bill,

    FindControl only searches for children immediately inside of the specified parent control, which is why you are having the problem.

    Since both RadComboBox controls are in the same edit template, they should have the same Parent, so an easy way I can see to do it would be something like this:  (Pardon me, my VB is rusty)

    Dim sourceDDL As RadComboBox = TryCast(o, RadComboBox)
    Dim DDL As RadComboBox = TryCast(sourceDDL.Parent.FindControl("rcbSecondComboBox"), RadComboBox)

    Hope that helps,
    Thad
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bill
    Bill avatar
    3 posts
    Member since:
    Jul 2011

    Posted 01 Aug 2011 Link to this post

    Thad,

    Thank you so much, that worked perfectly!
Back to Top