Button/Listbox problem

Neske

Member
Joined
Mar 1, 2005
Messages
17
Programming Experience
Beginner
Hi,

I have a page where you can give a mac address in a textbox en then you have to press a button and then i look for the matching items. I show the name of the matching items in a Listbox.
When you click on an item in the listbox a new page is loaded with all the information. But now comes my problem. When you use the back button to go to the previous page and on that page you give a new mac address and you push the button to seek the matching items, the information page of the last selected item in the listbox is showed.
Does anyone know what i can do about this problem.

Thanx

Neske
 
Hi,

I don't use a dataset, i get the items out of a reader. Could that be the reason then? That i have to use a dataset and no reader?

Thx
 
Hi,

Well i've tried to empty the reader. I have used a dataset instead of the reader but still it doesn't go.

Neske
 
Well i think maybe i have explained the problem wrong. Because i really don't think my code is wrong but maybe i have forgotten a property.
I'm going to try explain it again.
I have a page that's called SearchPc.aspx. On this page you enter a pc name. Then you have a button that"s called seek. When you press it, the pc name or names are shown in a listbox on the same page.
Then when you click on an item in the listbox i do a response.redirect to the page SearchPcDate.aspx. Then Normally there's a button Ok on that page, if you click it you go back to SearchPc.aspx. But you can also just use the button Back of you Internet Explorer to go to the previous page. Then you also come at SearchPc.aspx. Now the problem when you do that is: when you enter another name and you click the button Seek it doesn't seek anything but goes back to the page SearchPcDate.aspx. So he doesn't do the clickevent of the button but of the listbox.
And that is my problem, I hope someone has a solution.

Thx
Neske
 
Here it is

Private Sub ButtonZoeken_OnClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonZoeken.Click

connection = New Odbc.OdbcConnection("Dsn=Netwerk")
connection.Open()
query = "Select * from tblpc where Mac = '" & txtMac.text & "'
command = New Odbc.OdbcCommand(query, connection)
reader = command.ExecuteReader
If reader.HasRows Then
' Opvullen ComboBox
teller = 0
While reader.Read


Me.ListBoxResultaten.Items.Add(New ListItem(reader("PcSerienummer") & " " & reader("Pcnaam"), reader("Nummer")))
teller += 1
End While
Me.labelaantalrecords.Text = "aantal records: " & teller.ToString
Me.panelResultaten.Visible = True
Me.labelNietAanwezig.Visible = False
Else
Me.labelNietAanwezig.Visible = True
Me.panelResultaten.Visible = False
End If
end sub


Neske
 
Hi,

Now i know for sure that when they use the backbutton en they push the seek button that the code for the button isn't called. I filled a Session variable and when i hit the button if filled the variable with button and when i pressed the listbox with listbox. Then i did a response.write on the other page. And now i see that the variable is always listbox. So is there a way that i can erase the selected index from the listbox out of the memory?

Neske
 
Back
Top