Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page gets blank

Status
Not open for further replies.

ganjafarmerIT

Programmer
Jun 29, 2004
30
NL
Hi people,

I 'm getting a strange error. I only getting the error when i click dropdownlist(postback = on) and click it again before it has finished its first task.
Considering the people who are going to use the app this could become a huge problem.
Does anyone know how i can solve this.

Thanks in advance,

 
gan: Your dropdownlist's Select shouldn't fire on click, do you mean that if you choose yet a second option prior to the first? What does your code look like for the dropdown and event?
 
Can we see some of your code for loading the page and filling the drop down.

Also are you trying to do anything when you click on the drop down? If not, make sure AutoPostBack is set to False.

Hope everyone is having a great day!

Thanks - Jennifer
 
Isadore,

We must have been on the same wave length... :)

Hope everyone is having a great day!

Thanks - Jennifer
 
Jenn - its happened before - oh, by the way, I have been very impressed with your contributions of late, keep up the good work, and you too have a great day!
 
Isadore,
My mistake it fires on selectedIndez_changed
Here is my code:

Code:
        'The function worx like next:1. Count how many   results there are.  
        '2. Fill the array with the results.
        '3. The function then checks if the number of items in the dropdownlist are even to the items in the array.
        '4. If not the dropdownlist will be adjusted to size of the array.
        '5. Then all the items in the array are compared to those in the dropdownlist, 
	   'For example: item 1 in the array is compared to item 1 in the dropdownlist. If these aren't even the
	   'dropdownlist item is switched with item nr 1 from the array. etc.
	
	' this all is needed to keep the data in the dropdownlists up to date whenever the data changes in the database that's being populated in the dropdownlist.
	' It fixes the following problem: If dropdownlist 1 is populated, and right after that someone changes 
	'one of the values in the database that also exist in the dropdownlist,
	'then dropdownlist1 would still have the old value. If the user selects that value, the application would generate errors. 
	'because the old value doesn't exist in the database anymore.

        Try
            odbcConnectpublic.Open()
            Session.Item("OdbccommndO").CommandText = "select naam from groep order by naam;"
            Session.Item("myreader") = Session.Item("OdbccommndO").ExecuteReader()

            If Session.Item("myreader").HasRows Then

                While Session.Item("myreader").Read
                    'count the amount of items
                    Session.Item("vergelijkteller") = Session.Item("vergelijkteller") + 1
                End While
                ReDim Session.Item("vergelijkarrayI")(Session.Item("vergelijkteller") - 1)
            End If
        Catch ex As Exception
            costumfunction.log(ex.Message)
        Finally
            Session.Item("myreader").Close()
            odbcConnectpublic.Close()
        End Try

        'compare the amount of items in the dropdownlist with those in the array
        If ddlContractgroep.Items.Count - 1 < Session.Item("vergelijkteller") Then
            While ddlContractgroep.Items.Count - 1 <> Session.Item("vergelijkteller")
                ddlContractgroep.Items.Add("temp")
            End While
        ElseIf ddlContractgroep.Items.Count - 1 > Session.Item("vergelijkteller") Then
            While ddlContractgroep.Items.Count - 1 <> Session.Item("vergelijkteller")
                ddlContractgroep.Items.RemoveAt(1)
            End While
        End If
       
        Try
            odbcConnectpublic.Open()
            Session.Item("OdbccommndO").CommandText = "select naam from groep order by naam;"
            Session.Item("myreader") = Session.Item("OdbccommndO").ExecuteReader()

            Session.Item("vergelijkteller") = 0
            If Session.Item("myreader").HasRows Then
               
                While Session.Item("myreader").Read
                    'fill the array with the items
                    Session.Item("vergelijkarrayI")(Session.Item("vergelijkteller")) = Session.Item("myreader").GetString(0)
                    Session.Item("vergelijkteller") = Session.Item("vergelijkteller") + 1
                End While
            End If
        Catch ex As Exception
            costumfunction.log(ex.Message)
        Finally
            Session.Item("myreader").Close()
            odbcConnectpublic.Close()
        End Try

        Session.Item("vergelijkteller") = 1
        Session.Item("vergelijkteller2") = 0

        While Session.Item("loopT") < Session.Item("vergelijkarrayI").Length
            If Session.Item("vergelijkarrayI")(Session.Item("vergelijkteller2")).Equals(ddlContractgroep.Items.Item(Session.Item("vergelijkteller")).Text) = True Then
                Session.Item("vergelijkteller") = Session.Item("vergelijkteller") + 1
                Session.Item("vergelijkteller2") = Session.Item("vergelijkteller2") + 1
            Else
                ddlContractgroep.Items.RemoveAt(Session.Item("vergelijkteller"))
                ddlContractgroep.Items.Insert(Session.Item("vergelijkteller"), Session.Item("vergelijkarrayI")(Session.Item("vergelijkteller2")))
                Session.Item("vergelijkteller") = Session.Item("vergelijkteller") + 1
                Session.Item("vergelijkteller2") = Session.Item("vergelijkteller2") + 1
            End If
            Session.Item("loopT") = Session.Item("loopT") + 1
        End While
        Session.Item("loopT") = 0
        Session.Item("vergelijkteller") = 0
        Session.Item("vergelijkteller2") = 0
    End Function
 
ganjafarmerIT,
Your code is a bit odd as you delete the second item of the the dropdownlist as long as its count is larger than the array's. I don't know what the logic of your application is, thus I can't say that's right or wrong but it does look strange because, as it looks, you really don't know which items were changed in the database and therefore it wouldn't be wise to simply delete any item from the dropdown list. And just in case you don't know, the first item of a list is at index 0, not 1. But, then again, I don't know what your app's logic is so, if that's what you're supposed to be doing, simply disregard what I just said.

In any case, two questions: (1) What is the error that you're getting, and (2) which line of your code is causing it?

JC
 
thanks for your reply, I forgot to mention that there is a standard first value in the dropdownlist that isn't in the database. That's why it start's from the second value.

and for the error there is no error, the only thing that sometimes happens is that the page gets blank.

thanks in advance
 
Can't you have the Drop List Updated or Refreshed prior to the Selection? Trying to do it on the selection seems to allow the user to select faster than the code can complete.

Also, I have found that clearing and reloading the list is faster than trying to compare one item at a time.

Just my opionion...

Hope everyone is having a great day!

Thanks - Jennifer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top