ListBox Problem

Discussion in 'ASP .Net' started by CCORDON, Jan 10, 2005.

  1. CCORDON

    CCORDON Guest

    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.
     
    CCORDON, Jan 10, 2005
    #1
    1. Advertisements

  2. CCORDON

    Saravana Guest

    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



    "CCORDON" <> wrote in message news:%...
    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.
     
    Saravana, Jan 10, 2005
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DC Gringo
    Replies:
    0
    Views:
    556
    DC Gringo
    Apr 6, 2004
  2. kent
    Replies:
    1
    Views:
    1,029
    Andrew de la Harpe
    May 3, 2004
  3. Simon Prince
    Replies:
    2
    Views:
    3,583
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  4. Chris Kettenbach

    Listbox selection to populate another listbox?

    Chris Kettenbach, Jun 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,874
    Chris Kettenbach
    Jun 16, 2005
  5. bh_jodokast

    Drag from one listbox to another listbox

    bh_jodokast, Oct 7, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    538
    bh_jodokast
    Oct 7, 2005
  6. COHENMARVIN
    Replies:
    1
    Views:
    710
    =?Utf-8?B?U3JlZWppdGggUmFtKE1DU0QuTkVUKQ==?=
    Oct 14, 2005
  7. John Dalberg

    drag & drop from listbox to listbox?

    John Dalberg, Feb 21, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    983
    =?Utf-8?B?RFdT?=
    Feb 21, 2006
  8. Replies:
    0
    Views:
    423
Loading...