Results 1 to 4 of 4

Thread: [RESOLVED] After submission, the value from the Listbox is incorrect.

  1. #1

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

    Resolved [RESOLVED] After submission, the value from the Listbox is incorrect.

    I have this code inside of my button's event. The problem I am having is that the text input into the database is always the text from the first index of the listbox named categoryLst. I even used a listbox selection change event to change the text whenever the listbox was changed. But that became a lot more code and it still didn't work. I still get whatever is first in the list. I don't understand why this is happening. I am thinking it's a timing issue of some kind.

    Code:
                comm.Parameters.Add("@Relation", System.Data.SqlDbType.NVarChar, 20);
                comm.Parameters["@Relation"].Value = categoryLst.SelectedItem.Text;
    I need some help figuring out how I can get the text from the selection made, not the first one in the list. It's stuck and not changing for me when processing code. The user can change the selection in the list box and then hit the submit button. What is going on?

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: After submission, the value from the Listbox is incorrect.

    You need to show more code for the part of submit button click

  3. #3
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: After submission, the value from the Listbox is incorrect.

    Can you show the code of the submit button?

    EDIT: Oops, too late.

  4. #4

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

    Re: After submission, the value from the Listbox is incorrect.

    Using Page.IsPostBack solves the problem of accidentally rebinding the data and setting the list box back to it's default index.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width