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. Advertising

  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. Advertising

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. blenderdude
    Replies:
    0
    Views:
    969
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    398
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    874
    Andrew de la Harpe
    May 3, 2004
  4. Simon Prince
    Replies:
    2
    Views:
    3,320
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  5. Chris Kettenbach

    Listbox selection to populate another listbox?

    Chris Kettenbach, Jun 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,644
    Chris Kettenbach
    Jun 16, 2005
Loading...

Share This Page