Problem selecting item in radcombobox

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

David ModugnoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Where do you get that error?

I can imagine that the controls use a kind of deferred mode. So the items shown (loaded) are not necessarily the same as in the data source.

But this kind of question is better addressed to Telerik directly.
0
AndyAinscowFreelance programmer / ConsultantCommented:
While sdr.Read()
                Try

                    txtHeliLatDeg.Text = sdr(1).ToString()
....

As things use zero based indexing this sdr(1) will use the second field (column) of data and so on until, I suspect, the one more than the number of fields returned in the reader.
0
David ModugnoAuthor Commented:
I realize that it is zero based, I just don't need that value.
All of the other controls get filled without issue.
The problem happens in this section... it looks to see if there is a value returned for sdr(14)
in testing I always pick a project that will return a value.. I even placed the as a test
msgbox(sdr(14).ToString) -- in this case it returns "1"
so it should then should find the item value of "1" and select it
but I get the error
                    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

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

David ModugnoAuthor Commented:
any thoughts experts
thanks
0
AndyAinscowFreelance programmer / ConsultantCommented:
Strange.
Instead of this
                        'this is where the error happens
                        item = cmbPriHelo.FindItemByValue(sdr(14).ToString())
                        item.Selected = True
try
                        'this is where the error happens
dim s as string = sdr(14).ToString()
                        item = cmbPriHelo.FindItemByValue(s)
                        item.Selected = True

then put a breakpoint on the FindItemByValue line and check what s contains (or if it crashes with the same error before reaching the breakpoint)
0
David ModugnoAuthor Commented:
could it be that it is trying to find the value before the combobox has been populated?
0
David ModugnoAuthor Commented:
I think that is the case... I just did a test.. I added a button to the page and instead of calling my FillPage() sub in page load I am calling it from the button...
now it all works...
problem is I need it to fill the page on load...

from earlier .... I think it is because the safety page is a subpage of the radpageview and for some reason it is causing my combobox to not be filled soon enough ... I have a ticket open with telerek too, but so far they have not been much help and they are very slow... any help would be great
thanks
<telerik:RadPageView id="PageView4" runat="server" ContentURL="ProjSafety.aspx" Height="1000">

Open in new window

0
David ModugnoAuthor Commented:
turns out it was a problem with the timing.
by adding this to page load the problem has been resolved

 cmbPriHelo.DataBind()
 cmbSecHelo.DataBind()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David ModugnoAuthor Commented:
I managed to isolate the problem to a timing issue.. this was tested by creating a button and letting the page load complete before running the fill page sub.. everything now works after I forced the combo boxes to populate before I try and call them
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.