[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Help with moving to different screens

Posted on 2012-08-19
3
Medium Priority
?
506 Views
Last Modified: 2012-08-21
Hi,

I am moving through 10 screens using buttons (part A) and  a combobox (part B)
When I am on the last screens  by using the button Next event and try to go to the first screen using the combobox, I receive the following  error:

Conversion from string "" to type 'Double' is not valid.
On line: If C1ScreenA.SelectedValue = 1 Then

How do I fix this problem?

Thanks,

Part A:
Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnNext.Click
        hdnViewIndex.Value = CInt(LabelS2.Text) + 1
        LabelS2.Text = hdnViewIndex.Value
        If LabelS2.Text = 10 Then
            btnNext.Enabled = False
        End If
        SetActive()
End Sub
Private Sub SetActive()
        Dim ActiveView As Integer = CInt(hdnViewIndex.Value) + 1
        Dim ViewPanel As Panel
        For x As Integer = 1 To NumPanels
            ViewPanel = DirectCast(MultiView1.FindControl(String.Format("View{0}", x)), Panel)
            ViewPanel.Visible = (x = ActiveView)
        Next
    End Sub

Part B:

        If C1ScreenA.SelectedValue = 1 Then
            Dim ActiveView As Integer = CInt(2)
            Dim ViewPanel As Panel
            For x As Integer = 1 To NumPanels
                ViewPanel = DirectCast(MultiView1.FindControl(String.Format("View{0}", x)), Panel)
                ViewPanel.Visible = (x = ActiveView)
            Next
            LabelS2.Text = "1"
        End If

Victor
0
Comment
Question by:vcharles
3 Comments
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 1000 total points
ID: 38310431
SelectedValue is string returntype , if you compare this with int ie 1 you may get this issue.
For more info :
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.selectedvalue.aspx
'If C1ScreenA.SelectedValue = 1 Then
change to and its safe to compare like below,
If C1ScreenA.SelectedValue = "1" Then

Open in new window

0
 
LVL 25

Assisted Solution

by:Rouchie
Rouchie earned 1000 total points
ID: 38310837
The error actually means that you cannot change an EMPTY string into a Double.  So the underlying problem is either...

1) The listcontrol has no items
2) The listcontrol does not have a selected item
3) The listcontrol's selected item value is an empty string

I think option 3 is the problem, so you need to check using something like this:

If C1ScreenA.SelectedIndex <> -1 AndAlso C1ScreenA.SelectedItem.Value <> String.Empty AndAlso IsNumeric(C1ScreenA.SelectedItem.Value) Then
      If C1ScreenA.SelectedValue = 1 Then
          ' ..............
      End If
End If

Open in new window

0
 

Author Comment

by:vcharles
ID: 38315382
Hi,

I am not sure wwhat was wrong but when I install the app to another server, all seems to be working ok.

Thanks,

Victor
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question