This is a migrated thread and some comments may be shown as answers.
RadComboBox OnSelectedIndexChanged
2 Answers 78 Views
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 01 Aug 2011, 04:04 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Thad
Top achievements
Rank 2
answered on 01 Aug 2011, 10:41 PM
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
0
Bill
Top achievements
Rank 1
answered on 02 Aug 2011, 01:13 AM
Thad,

Thank you so much, that worked perfectly!
Asked by
Bill
Top achievements
Rank 1
Answers by
Thad
Top achievements
Rank 2
Bill
Top achievements
Rank 1
Share this question
or