ListBox Problem

C

CCORDON

I have a problem with a listbox. I shows a number of records from a DB. ItemData = ProductId, ItemText = ProductName. It loads great. But when the user clicks on one of the items, this code:

Dim MyItem As New ListItem

MyItem = lstItems.SelectedItem

If Not (MyItem Is Nothing) Then

Dim MyProd As New Producto

Session("ResultMessage") = MyProd.Delete(lstItems.SelectedItem.Value)

Response.Redirect("Result.aspx?RedirectPage=Productos.aspx")

End If



Always returns the first item in the listbox.



Help Please.
 
S

Saravana

Before checking the selectedItem of listbox, are you binding the listbox again in page_load. If so then check for postback using ispostback property and then bind it.


--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com



I have a problem with a listbox. I shows a number of records from a DB. ItemData = ProductId, ItemText = ProductName. It loads great. But when the user clicks on one of the items, this code:

Dim MyItem As New ListItem

MyItem = lstItems.SelectedItem

If Not (MyItem Is Nothing) Then

Dim MyProd As New Producto

Session("ResultMessage") = MyProd.Delete(lstItems.SelectedItem.Value)

Response.Redirect("Result.aspx?RedirectPage=Productos.aspx")

End If



Always returns the first item in the listbox.



Help Please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top