We help IT Professionals succeed at work.
Get Started

Problem selecting item in radcombobox

David Modugno
on
207 Views
Last Modified: 2015-10-11
I have a project that uses telerik controls... I'm using a radtabstrip (just creates tabs in a page).. one tab is called safety..
I have another page that is displayed inside the tabstrip

On that page I have two radcombo boxes that are filled by a sqldatasource
I also have a sub that is used to fill all the controls on the page with information from sql.
in the case of the comboxes it takes the keyfiled (just a number) finds that number in the combobox and selects that item
for some reason I am getting an out of range error...

Here is the section where I select the value of the combobox (the entire sub will follow)
thanks in advance experts
Dim item As RadComboBoxItem = Nothing
                    If sdr(14).ToString = "" Then
                        item = cmbPriHelo.FindItemByValue("Helicopter")
                        item.Selected = True
                        'cmbPriHelo.Items.FindItemByValue("Helicopter").Selected = True
                    Else
                        'this is where the error happens
                        item = cmbPriHelo.FindItemByValue(sdr(14).ToString())
                        item.Selected = True
                    End If

Open in new window


 Private Sub FillForm()
        Dim ProjId As String = ProjectInfo.ProjID
        Dim strConnString As String = ConfigurationManager.ConnectionStrings("TimberOpsConnectionString").ConnectionString
        Dim strQuery As String = "select KEYField, Lat_Degrees1, Lat_Minutes1, Lat_Seconds1, Long_Degrees1, Long_Minutes1, Long_Seconds1, LandingZoneDesc, LZ_Average_Elevation, Evac_Form_Authorized, JS_Radio_Comm, JS_Mobile_Comm, JS_Designated_Comm_Pt, JS_Comm_Pt_Description, Primary_Helicopter, Secondary_Helicopter from tblProject where KEYField = " & ProjId
        Dim con As New SqlConnection(strConnString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.Text
        cmd.CommandText = strQuery
        cmd.Connection = con
        Try
            con.Open()
            Dim sdr As SqlDataReader = cmd.ExecuteReader()
            While sdr.Read()
                Try

                    txtHeliLatDeg.Text = sdr(1).ToString()
                    txtHeliLatMin.Text = sdr(2).ToString()
                    txtHeliLatSec.Text = sdr(3).ToString()
                    txtHeliLongDeg.Text = sdr(4).ToString()
                    txtHeliLongMin.Text = sdr(5).ToString()
                    txtHeliLongSec.Text = sdr(6).ToString()
                    txtLZoneDesc.Text = sdr(7).ToString()
                    txtLZoneElevation.Text = sdr(8).ToString()
                    If sdr(9).ToString = "True" Then
                        btnAppEvacForm.Checked = True
                    Else
                        btnAppEvacForm.Checked = False
                    End If
                    If sdr(10).ToString = "True" Then
                        btnJobSiteRadio.Checked = True
                    Else
                        btnJobSiteRadio.Checked = False
                    End If
                    If sdr(11).ToString = "True" Then
                        btnJobSiteMobileComm.Checked = True
                    Else
                        btnJobSiteMobileComm.Checked = False
                    End If

                    If sdr(12).ToString = "True" Then
                        btnDesCommPt.Checked = True
                    Else
                        btnDesCommPt.Checked = False
                    End If
                    txtCommPointDesc.Text = sdr(13).ToString()
                    Dim item As RadComboBoxItem = Nothing
                    If sdr(14).ToString = "" Then
                        item = cmbPriHelo.FindItemByValue("Helicopter")
                        item.Selected = True
                        'cmbPriHelo.Items.FindItemByValue("Helicopter").Selected = True
                    Else
                        'this is where the error happens
                        item = cmbPriHelo.FindItemByValue(sdr(14).ToString())
                        item.Selected = True
                    End If
                    MsgBox("made it here")
                    If sdr(15).ToString = "" Then
                        'cmbSecHelo.Items.FindItemByValue("Helicopter").Selected = True
                    Else
                        cmbSecHelo.Items.FindItemByValue(sdr(15).ToString()).Selected = True
                    End If
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try

            End While
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()
            con.Dispose()
        End Try
    End Sub

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE